mkrf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/MIT-LICENSE +7 -0
- data/README +54 -0
- data/Rakefile +107 -0
- data/lib/mkrf.rb +4 -0
- data/lib/mkrf/availability.rb +219 -0
- data/lib/mkrf/generator.rb +146 -0
- data/test/abstract_unit.rb +4 -0
- data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
- data/test/fixtures/stdmkrf.h +1 -0
- data/test/sample_files/libtrivial/Rakefile +31 -0
- data/test/sample_files/libtrivial/extconf.rb +3 -0
- data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
- data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
- data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
- data/test/sample_files/libtrivial/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
- data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
- data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
- data/test/sample_files/syck-0.55/CHANGELOG +186 -0
- data/test/sample_files/syck-0.55/COPYING +54 -0
- data/test/sample_files/syck-0.55/Makefile +582 -0
- data/test/sample_files/syck-0.55/Makefile.am +5 -0
- data/test/sample_files/syck-0.55/Makefile.in +582 -0
- data/test/sample_files/syck-0.55/README +105 -0
- data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
- data/test/sample_files/syck-0.55/README.EXT +444 -0
- data/test/sample_files/syck-0.55/RELEASE +123 -0
- data/test/sample_files/syck-0.55/TODO +25 -0
- data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
- data/test/sample_files/syck-0.55/bootstrap +7 -0
- data/test/sample_files/syck-0.55/config.h +79 -0
- data/test/sample_files/syck-0.55/config.h.in +78 -0
- data/test/sample_files/syck-0.55/config.status +1197 -0
- data/test/sample_files/syck-0.55/config/README +14 -0
- data/test/sample_files/syck-0.55/config/depcomp +529 -0
- data/test/sample_files/syck-0.55/config/install-sh +323 -0
- data/test/sample_files/syck-0.55/config/missing +357 -0
- data/test/sample_files/syck-0.55/configure +6728 -0
- data/test/sample_files/syck-0.55/configure.in +36 -0
- data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
- data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
- data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
- data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
- data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
- data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
- data/test/sample_files/syck-0.55/lib/Makefile +497 -0
- data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
- data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
- data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
- data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
- data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
- data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
- data/test/sample_files/syck-0.55/lib/gram.h +79 -0
- data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
- data/test/sample_files/syck-0.55/lib/gram.y +481 -0
- data/test/sample_files/syck-0.55/lib/handler.c +174 -0
- data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
- data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
- data/test/sample_files/syck-0.55/lib/node.c +407 -0
- data/test/sample_files/syck-0.55/lib/syck.c +504 -0
- data/test/sample_files/syck-0.55/lib/syck.h +458 -0
- data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
- data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
- data/test/sample_files/syck-0.55/lib/token.c +2707 -0
- data/test/sample_files/syck-0.55/lib/token.re +1139 -0
- data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
- data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
- data/test/sample_files/syck-0.55/stamp-h1 +1 -0
- data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
- data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
- data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
- data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
- data/test/sample_files/syck-0.55/tests/Makefile +480 -0
- data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
- data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
- data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
- data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
- data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
- data/test/test_availability.rb +68 -0
- data/test/test_generator.rb +74 -0
- metadata +252 -0
@@ -0,0 +1 @@
|
|
1
|
+
#define DOWN_A_DIRECTORY
|
@@ -0,0 +1 @@
|
|
1
|
+
#define MKRF
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
|
3
|
+
CLEAN.include('*.o')
|
4
|
+
CLOBBER.include('libtrivial_so.bundle')
|
5
|
+
|
6
|
+
SRC = FileList[]
|
7
|
+
OBJ = SRC.ext('o')
|
8
|
+
CC = "gcc"
|
9
|
+
|
10
|
+
LDSHARED = "cc -dynamic -bundle -undefined suppress -flat_namespace"
|
11
|
+
LIBPATH = '-L"/usr/local/lib"'
|
12
|
+
|
13
|
+
INCLUDES = "-I/usr/local/include -I/usr/local/lib/ruby/1.8/i686-darwin8.6.1 -I/usr/local/lib/ruby/site_ruby/1.8 -I."
|
14
|
+
|
15
|
+
LIBS = "-lruby -ldl"
|
16
|
+
|
17
|
+
CFLAGS = " -fno-common -g -O2 -pipe -fno-common "
|
18
|
+
|
19
|
+
task :default => ['libtrivial_so.bundle']
|
20
|
+
|
21
|
+
rule '.o' => '.c' do |t|
|
22
|
+
sh "#{CC} #{CFLAGS} #{INCLUDES} -c -o #{t.name} #{t.source}"
|
23
|
+
end
|
24
|
+
|
25
|
+
rule '.so' => '.o' do |t|
|
26
|
+
sh "#{LDSHARED} #{LIBPATH} -o #{OBJ} #{LOCAL_LIBS} #{LIBS}"
|
27
|
+
end
|
28
|
+
|
29
|
+
file 'libtrivial_so.bundle' => OBJ do
|
30
|
+
sh "#{LDSHARED} #{LIBPATH} -o libtrivial_so.bundle #{OBJ} #{LIBS}"
|
31
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
# Logfile created on Mon Jun 26 15:47:07 PDT 2006 by logger.rb/1.5.2.7
|
@@ -0,0 +1,74 @@
|
|
1
|
+
===== 15.4.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
2
|
+
* Implemented SAX parser callback handling
|
3
|
+
|
4
|
+
===== 12.4.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
5
|
+
* Integrated / tested community patches
|
6
|
+
* Defined XML::Node (hash) equality in terms of XML representation
|
7
|
+
|
8
|
+
===== 12.4.2006 Tim Yamin <plasmaroo at gentoo.org> (patches)
|
9
|
+
* Fixed XML::Node#content inoperable bug
|
10
|
+
* Fixed memory leak in same
|
11
|
+
|
12
|
+
===== 12.4.2006 Mark Van Holstyn <mvette13 at gmail.com> (patches)
|
13
|
+
* Added XML::Node::Set#first
|
14
|
+
* Added XML::Node::Set#empty?
|
15
|
+
* Fixes to XML::Node::Set#to_a
|
16
|
+
* Added XML::Node#find_first
|
17
|
+
* Added XML::Node#remove!
|
18
|
+
|
19
|
+
===== 27.3.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
20
|
+
* Integrated contributed XML::Parser.register_error_handler patch
|
21
|
+
|
22
|
+
===== 27.2.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
23
|
+
* Fixed all multiple symbol definitions for -fno-common.
|
24
|
+
* Removed OSX -fno-common workaround.
|
25
|
+
|
26
|
+
===== 21.2.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
27
|
+
* Patched extconf.rb with OSX -fno-common workaround
|
28
|
+
* Added gem and packaging support to Rakefile
|
29
|
+
* Moved version update to Rakefile
|
30
|
+
* Removed legacy project utility scripts
|
31
|
+
|
32
|
+
===== 19.2.2006 Ross Bamford <rosco at roscopeco.co.uk>
|
33
|
+
* Fixed doublefree bug in ruby_xml_attr.
|
34
|
+
* Fixed small leak in parser
|
35
|
+
|
36
|
+
===== 18.12.2005 Ross Bamford <rosco at roscopeco.co.uk>
|
37
|
+
* Updated for GCC 4.0 (community patches)
|
38
|
+
* Fixed default validation bug
|
39
|
+
* Refactored project, removed outdated files, cleaned up tests.
|
40
|
+
* Added RDoc documentation across .c files.
|
41
|
+
* Fixed up a few strings.
|
42
|
+
|
43
|
+
===== 14.4.2004 Mangler Jurgen <et@wkv.at>
|
44
|
+
* ruby_xml_node.cz: fixed ruby_xml_node_property_set. The ill-behaviour
|
45
|
+
was, that there was added a second attribute of the same
|
46
|
+
name, when you were setting the value of an already existing
|
47
|
+
attribute.
|
48
|
+
|
49
|
+
===== 17.3.2004 Lukas Svoboda <luks@fi.muni.cz>
|
50
|
+
* ruby_xml_node.c: ruby_xml_node_to_s now returns XML subtree dump.
|
51
|
+
|
52
|
+
===== 27.2.2004 Martin Povolny <martin@solnet.cz>
|
53
|
+
* ruby_xml_node.c: added XML::Node.copy, this makes possible building
|
54
|
+
of xml documents from nodes taken from other xml documents
|
55
|
+
without making ruby SIGSEGV (see tests/copy_bug.rb).
|
56
|
+
|
57
|
+
===== 26.2.2004 Martin Povolny <martin@solnet.cz>
|
58
|
+
* ruby_xml_dtd.c, ruby_xml_dtd.h, ruby_xml_schema.c, ruby_xml_schema.h:
|
59
|
+
more work on validation, now you can actually validate
|
60
|
+
document using dtd or xml schema, also solved warning and
|
61
|
+
error propagation (see tests/{dtd|schema}-test.rb).
|
62
|
+
|
63
|
+
===== 30.12.2003 Martin Povolny <martin@solnet.cz>
|
64
|
+
* ruby_xml_dtd.c, ruby_xml_dtd.h, ruby_xml_schema.c, ruby_xml_schema.h:
|
65
|
+
prelimitary support for dtd and schema validation
|
66
|
+
|
67
|
+
===== 15.9.2003 Martin Povolny <martin@solnet.cz>
|
68
|
+
* ruby_xml_input_cbg.c, libxml.c: added class InputCallbacks to make
|
69
|
+
possible registering custom input callbacks
|
70
|
+
handlers (xmlRegisterInputCallbacks) written in ruby
|
71
|
+
|
72
|
+
===== 1.8.2003 Martin Povolny <martin@solnet.cz>
|
73
|
+
* ruby_xml_document.c: corrected argument handling in ruby_xml_document_find
|
74
|
+
* ruby_xml_node.c: corrected argument handling in ruby_xml_node_find
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# $Id: LICENSE,v 1.3 2006/02/28 09:57:52 roscopeco Exp $
|
2
|
+
|
3
|
+
Copyright (c) 2002-2006 Sean Chittenden <sean@chittenden.org> and contributors
|
4
|
+
Copyright (c) 2001 Wai-Sun "Squidster" Chia <waisun.chia@compaq.com>
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
8
|
+
the Software without restriction, including without limitation the rights to
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
10
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
11
|
+
so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
@@ -0,0 +1,144 @@
|
|
1
|
+
== INSTALLATION
|
2
|
+
|
3
|
+
Installation is simple. Follow the following steps:
|
4
|
+
|
5
|
+
=== Rubygems
|
6
|
+
|
7
|
+
gem install libxml-ruby
|
8
|
+
|
9
|
+
=== Tarball/zip
|
10
|
+
|
11
|
+
$ rake test
|
12
|
+
$ rake install
|
13
|
+
|
14
|
+
If extconf yacks up an error, follow the instructions it provides.
|
15
|
+
You will need to chdir to ext/xml and run 'ruby extconf.rb' to provide
|
16
|
+
options, after which you can either use Rake for everything or
|
17
|
+
do with make (make && make install).
|
18
|
+
|
19
|
+
Once installed, look at the test scripts (tests/*.rb), and run
|
20
|
+
'rake doc' to generate API documentation.
|
21
|
+
You can find the latest documentation at:
|
22
|
+
|
23
|
+
* http://libxml.rubyforge.org/doc
|
24
|
+
|
25
|
+
== DEPENDENCIES
|
26
|
+
|
27
|
+
libxml requires a few other libraries to be installed inorder to
|
28
|
+
function properly.
|
29
|
+
|
30
|
+
* libm (math routines: very standard)
|
31
|
+
* libz (zlib)
|
32
|
+
* libiconv
|
33
|
+
* libxml2
|
34
|
+
|
35
|
+
== USAGE
|
36
|
+
|
37
|
+
Basic usage for reading and writing documents.
|
38
|
+
|
39
|
+
=== WRITING
|
40
|
+
|
41
|
+
Writing a simple document:
|
42
|
+
|
43
|
+
# require 'rubygems' # if installed via Gems
|
44
|
+
require 'xml/libxml'
|
45
|
+
|
46
|
+
doc = XML::Document.new()
|
47
|
+
doc.root = XML::Node.new('root_node')
|
48
|
+
root = doc.root
|
49
|
+
|
50
|
+
root << elem1 = XML::Node.new('elem1')
|
51
|
+
elem1['attr1'] = 'val1'
|
52
|
+
elem1['attr2'] = 'val2'
|
53
|
+
|
54
|
+
root << elem2 = XML::Node.new('elem2')
|
55
|
+
elem2['attr1'] = 'val1'
|
56
|
+
elem2['attr2'] = 'val2'
|
57
|
+
|
58
|
+
root << elem3 = XML::Node.new('elem3')
|
59
|
+
elem3 << elem4 = XML::Node.new('elem4')
|
60
|
+
elem3 << elem5 = XML::Node.new('elem5')
|
61
|
+
|
62
|
+
elem5 << elem6 = XML::Node.new('elem6')
|
63
|
+
elem6 << 'Content for element 6'
|
64
|
+
|
65
|
+
elem3['attr'] = 'baz'
|
66
|
+
|
67
|
+
# Namespace hack to reduce the numer of times XML:: is typed
|
68
|
+
include XML
|
69
|
+
root << elem7 = Node.new('foo')
|
70
|
+
1.upto(10) do |i|
|
71
|
+
elem7 << n = Node.new('bar')
|
72
|
+
n << i
|
73
|
+
end
|
74
|
+
|
75
|
+
format = true
|
76
|
+
doc.save('output.xml', format)
|
77
|
+
|
78
|
+
The file output.xml contains:
|
79
|
+
|
80
|
+
<?xml version="1.0"?>
|
81
|
+
<root_node>
|
82
|
+
<elem1 attr1="val1" attr2="val2"/>
|
83
|
+
<elem2 attr1="val1" attr2="val2"/>
|
84
|
+
<elem3 attr="baz">
|
85
|
+
<elem4/>
|
86
|
+
<elem5>
|
87
|
+
<elem6>Content for element 6</elem6>
|
88
|
+
</elem5>
|
89
|
+
</elem3>
|
90
|
+
<foo>
|
91
|
+
<bar>1</bar>
|
92
|
+
<bar>2</bar>
|
93
|
+
<bar>3</bar>
|
94
|
+
<bar>4</bar>
|
95
|
+
<bar>5</bar>
|
96
|
+
<bar>6</bar>
|
97
|
+
<bar>7</bar>
|
98
|
+
<bar>8</bar>
|
99
|
+
<bar>9</bar>
|
100
|
+
<bar>10</bar>
|
101
|
+
</foo>
|
102
|
+
</root_node>
|
103
|
+
|
104
|
+
=== READING
|
105
|
+
|
106
|
+
Reading XML is slightly more complex and there are many more ways to
|
107
|
+
perform this operation. This reads in and processes the above
|
108
|
+
generated XML document, output.xml. This script assumes that the
|
109
|
+
structure of the document is already known.
|
110
|
+
|
111
|
+
# require 'rubygems' # if installed via Gems
|
112
|
+
require 'xml/libxml'
|
113
|
+
doc = XML::Document.file('output.xml')
|
114
|
+
root = doc.root
|
115
|
+
|
116
|
+
puts "Root element name: #{root.name}"
|
117
|
+
|
118
|
+
elem3 = root.find('elem3').to_a.first
|
119
|
+
puts "Elem3: #{elem3['attr']}"
|
120
|
+
|
121
|
+
doc.find('//root_node/foo/bar').each do |node|
|
122
|
+
puts "Node path: #{node.path} \t Contents: #{node}"
|
123
|
+
end
|
124
|
+
|
125
|
+
And your terminal should look like:
|
126
|
+
|
127
|
+
Root element name: root_node
|
128
|
+
Elem3: baz
|
129
|
+
Node path: /root_node/foo/bar[1] Contents: 1
|
130
|
+
Node path: /root_node/foo/bar[2] Contents: 2
|
131
|
+
Node path: /root_node/foo/bar[3] Contents: 3
|
132
|
+
Node path: /root_node/foo/bar[4] Contents: 4
|
133
|
+
Node path: /root_node/foo/bar[5] Contents: 5
|
134
|
+
Node path: /root_node/foo/bar[6] Contents: 6
|
135
|
+
Node path: /root_node/foo/bar[7] Contents: 7
|
136
|
+
Node path: /root_node/foo/bar[8] Contents: 8
|
137
|
+
Node path: /root_node/foo/bar[9] Contents: 9
|
138
|
+
Node path: /root_node/foo/bar[10] Contents: 10
|
139
|
+
|
140
|
+
== MORE INFORMATION
|
141
|
+
|
142
|
+
If you have any questions, please send email to libxml-devel@rubyforge.org.
|
143
|
+
|
144
|
+
# $Id: README,v 1.5 2006/04/24 19:29:49 roscopeco Exp $
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include <libxml/xmlIO.h>
|
3
|
+
#include "ruby.h"
|
4
|
+
|
5
|
+
/*
|
6
|
+
int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
7
|
+
xmlInputOpenCallback openFunc,
|
8
|
+
xmlInputReadCallback readFunc,
|
9
|
+
xmlInputCloseCallback closeFunc);
|
10
|
+
|
11
|
+
|
12
|
+
int (*xmlInputMatchCallback) (char const *filename);
|
13
|
+
void* (*xmlInputOpenCallback) (char const *filename);
|
14
|
+
int (*xmlInputReadCallback) (void *context,
|
15
|
+
char *buffer,
|
16
|
+
int len);
|
17
|
+
int (*xmlInputCloseCallback) (void *context);
|
18
|
+
*/
|
19
|
+
|
20
|
+
typedef struct deb_doc_context {
|
21
|
+
char *buffer;
|
22
|
+
char *bpos;
|
23
|
+
int remaining;
|
24
|
+
} deb_doc_context;
|
25
|
+
|
26
|
+
int deb_Match (char const *filename) {
|
27
|
+
fprintf( stderr, "deb_Match: %s\n", filename );
|
28
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6)) {
|
29
|
+
return(1);
|
30
|
+
}
|
31
|
+
return(0);
|
32
|
+
}
|
33
|
+
|
34
|
+
void* deb_Open (char const *filename) {
|
35
|
+
deb_doc_context *deb_doc;
|
36
|
+
VALUE res;
|
37
|
+
|
38
|
+
deb_doc = (deb_doc_context*)malloc( sizeof(deb_doc_context) );
|
39
|
+
|
40
|
+
res = rb_funcall( rb_funcall( rb_mKernel, rb_intern("const_get"), 1, rb_str_new2("DEBSystem") ),
|
41
|
+
rb_intern("document_query"), 1, rb_str_new2(filename));
|
42
|
+
deb_doc->buffer = strdup( StringValuePtr(res) );
|
43
|
+
//deb_doc->buffer = strdup("<serepes>serepes</serepes>");
|
44
|
+
|
45
|
+
deb_doc->bpos = deb_doc->buffer;
|
46
|
+
deb_doc->remaining = strlen(deb_doc->buffer);
|
47
|
+
return deb_doc;
|
48
|
+
}
|
49
|
+
|
50
|
+
int deb_Read (void *context, char *buffer, int len) {
|
51
|
+
deb_doc_context *deb_doc;
|
52
|
+
int ret_len;
|
53
|
+
deb_doc = (deb_doc_context*)context;
|
54
|
+
|
55
|
+
if (len >= deb_doc->remaining) {
|
56
|
+
ret_len = deb_doc->remaining;
|
57
|
+
} else {
|
58
|
+
ret_len = len;
|
59
|
+
}
|
60
|
+
deb_doc->remaining -= ret_len;
|
61
|
+
strncpy( buffer, deb_doc->bpos, ret_len );
|
62
|
+
deb_doc->bpos += ret_len;
|
63
|
+
|
64
|
+
return ret_len;
|
65
|
+
}
|
66
|
+
|
67
|
+
int deb_Close (void *context) {
|
68
|
+
free( ((deb_doc_context*)context)->buffer );
|
69
|
+
free( context );
|
70
|
+
return 1;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
void deb_register_cbg() {
|
75
|
+
xmlRegisterInputCallbacks( deb_Match, deb_Open, deb_Read, deb_Close );
|
76
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require '../../../../../lib/mkrf'
|
2
|
+
|
3
|
+
def crash(str)
|
4
|
+
printf(" extconf failure: %s\n", str)
|
5
|
+
exit 1
|
6
|
+
end
|
7
|
+
|
8
|
+
Mkrf::Generator.new('libxml_so.bundle', '*.c') do |g|
|
9
|
+
|
10
|
+
g.include_library('socket','socket')
|
11
|
+
g.include_library('nsl','gethostbyname')
|
12
|
+
|
13
|
+
unless g.include_library('z', 'inflate')
|
14
|
+
crash('need zlib')
|
15
|
+
else
|
16
|
+
g.add_define('HAVE_ZLIB_H')
|
17
|
+
end
|
18
|
+
|
19
|
+
unless g.include_library('iconv','iconv_open') or
|
20
|
+
g.include_library('c','iconv_open') or
|
21
|
+
g.include_library('recode','iconv_open') or
|
22
|
+
g.include_library('iconv')
|
23
|
+
crash(<<-EOL)
|
24
|
+
need libiconv.
|
25
|
+
|
26
|
+
Install the libiconv or try passing one of the following options
|
27
|
+
to extconf.rb:
|
28
|
+
|
29
|
+
--with-iconv-dir=/path/to/iconv
|
30
|
+
--with-iconv-lib=/path/to/iconv/lib
|
31
|
+
--with-iconv-include=/path/to/iconv/include
|
32
|
+
EOL
|
33
|
+
end
|
34
|
+
|
35
|
+
g.include_library('xml2', 'xmlParseDoc')
|
36
|
+
has_header = g.include_header('libxml/xmlversion.h',
|
37
|
+
'/opt/include/libxml2',
|
38
|
+
'/usr/local/include/libxml2',
|
39
|
+
'/usr/include/libxml2')
|
40
|
+
|
41
|
+
unless g.include_library('xml2', 'xmlDocFormatDump')
|
42
|
+
crash('Your version of libxml2 is too old. Please upgrade.')
|
43
|
+
end
|
44
|
+
|
45
|
+
unless g.has_function? 'docbCreateFileParserCtxt'
|
46
|
+
crash('Need docbCreateFileParserCtxt')
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/* $Id: libxml.c,v 1.2 2006/04/17 13:30:22 roscopeco Exp $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "libxml.h"
|
6
|
+
|
7
|
+
/* Ruby's util.h has ruby_strdup */
|
8
|
+
#include "util.h"
|
9
|
+
|
10
|
+
#ifdef xmlMalloc
|
11
|
+
#undef xmlMalloc
|
12
|
+
#endif
|
13
|
+
#ifdef xmlRealloc
|
14
|
+
#undef xmlRealloc
|
15
|
+
#endif
|
16
|
+
#ifdef xmlMemStrdup
|
17
|
+
#undef xmlMemStrdup
|
18
|
+
#endif
|
19
|
+
#ifdef xmlMemFree
|
20
|
+
#undef xmlMemFree
|
21
|
+
#endif
|
22
|
+
|
23
|
+
#ifdef RubyMemMalloc
|
24
|
+
#undef RubyMemMalloc
|
25
|
+
#endif
|
26
|
+
#ifdef RubyMemRealloc
|
27
|
+
#undef RubyMemRealloc
|
28
|
+
#endif
|
29
|
+
#ifdef RubyMemStrdup
|
30
|
+
#undef RubyMemStrdup
|
31
|
+
#endif
|
32
|
+
#ifdef RubyMemFree
|
33
|
+
#undef RubyMemFree
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#define RubyMemFree ruby_xfree
|
37
|
+
#define RubyMemRealloc ruby_xrealloc
|
38
|
+
#define RubyMemMalloc ruby_xmalloc
|
39
|
+
#define RubyMemStrdup ruby_strdup
|
40
|
+
|
41
|
+
VALUE mXML;
|
42
|
+
|
43
|
+
static xmlFreeFunc freeFunc = NULL;
|
44
|
+
static xmlMallocFunc mallocFunc = NULL;
|
45
|
+
static xmlReallocFunc reallocFunc = NULL;
|
46
|
+
static xmlStrdupFunc strdupFunc = NULL;
|
47
|
+
|
48
|
+
void
|
49
|
+
Init_libxml_so(void) {
|
50
|
+
/* Some libxml memory goo that should be done before anything else */
|
51
|
+
xmlMemGet((xmlFreeFunc *) & freeFunc,
|
52
|
+
(xmlMallocFunc *) & mallocFunc,
|
53
|
+
(xmlReallocFunc *) & reallocFunc,
|
54
|
+
(xmlStrdupFunc *) & strdupFunc);
|
55
|
+
|
56
|
+
if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc,
|
57
|
+
(xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0)
|
58
|
+
rb_fatal("could not install the memory handlers for libxml");
|
59
|
+
xmlInitParser();
|
60
|
+
|
61
|
+
mXML = rb_define_module("XML");
|
62
|
+
|
63
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*)XML_XML_NAMESPACE));
|
64
|
+
|
65
|
+
ruby_init_parser();
|
66
|
+
ruby_init_xml_parser_context();
|
67
|
+
ruby_init_xml_attr();
|
68
|
+
ruby_init_xml_attribute();
|
69
|
+
ruby_init_xml_document();
|
70
|
+
ruby_init_xml_node();
|
71
|
+
ruby_init_xml_node_set();
|
72
|
+
ruby_init_xml_ns();
|
73
|
+
ruby_init_xml_sax_parser();
|
74
|
+
ruby_init_xml_tree();
|
75
|
+
ruby_init_xml_xinclude();
|
76
|
+
ruby_init_xml_xpath();
|
77
|
+
ruby_init_xml_xpath_context();
|
78
|
+
ruby_init_xml_xpointer();
|
79
|
+
ruby_init_xml_xpointer_context();
|
80
|
+
ruby_init_input_callbacks(); /* MUFF */
|
81
|
+
ruby_init_xml_dtd(); /* MUFF */
|
82
|
+
ruby_init_xml_schema(); /* MUFF */
|
83
|
+
|
84
|
+
ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue);
|
85
|
+
ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue);
|
86
|
+
}
|