mkrf 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +2 -0
  2. data/MIT-LICENSE +7 -0
  3. data/README +54 -0
  4. data/Rakefile +107 -0
  5. data/lib/mkrf.rb +4 -0
  6. data/lib/mkrf/availability.rb +219 -0
  7. data/lib/mkrf/generator.rb +146 -0
  8. data/test/abstract_unit.rb +4 -0
  9. data/test/fixtures/down_a_directory/header_down_a_directory.h +1 -0
  10. data/test/fixtures/stdmkrf.h +1 -0
  11. data/test/sample_files/libtrivial/Rakefile +31 -0
  12. data/test/sample_files/libtrivial/extconf.rb +3 -0
  13. data/test/sample_files/libtrivial/lib/libtrivial.c +5 -0
  14. data/test/sample_files/libtrivial/lib/libtrivial.o +0 -0
  15. data/test/sample_files/libtrivial/libtrivial_so.bundle +0 -0
  16. data/test/sample_files/libtrivial/mkrf.log +1 -0
  17. data/test/sample_files/libxml-ruby-0.3.8/CHANGELOG +74 -0
  18. data/test/sample_files/libxml-ruby-0.3.8/LICENSE +22 -0
  19. data/test/sample_files/libxml-ruby-0.3.8/README +144 -0
  20. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/cbg.c +76 -0
  21. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/extconf.rb +49 -0
  22. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.c +86 -0
  23. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.h +82 -0
  24. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/libxml.rb +107 -0
  25. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/mkrf.log +1 -0
  26. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/old_extconf.rb +95 -0
  27. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.c +372 -0
  28. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attr.h +21 -0
  29. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.c +224 -0
  30. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_attribute.h +21 -0
  31. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.c +1159 -0
  32. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_document.h +27 -0
  33. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.c +168 -0
  34. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_dtd.h +17 -0
  35. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.c +167 -0
  36. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_input_cbg.h +21 -0
  37. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.c +2139 -0
  38. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node.h +28 -0
  39. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.c +248 -0
  40. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_node_set.h +26 -0
  41. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.c +153 -0
  42. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_ns.h +21 -0
  43. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.c +1417 -0
  44. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser.h +31 -0
  45. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.c +715 -0
  46. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_parser_context.h +22 -0
  47. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.c +426 -0
  48. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_sax_parser.h +52 -0
  49. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.c +142 -0
  50. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_schema.h +16 -0
  51. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.c +43 -0
  52. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_tree.h +12 -0
  53. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.c +20 -0
  54. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xinclude.h +13 -0
  55. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.c +363 -0
  56. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath.h +24 -0
  57. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.c +125 -0
  58. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpath_context.h +24 -0
  59. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.c +100 -0
  60. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer.h +27 -0
  61. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.c +21 -0
  62. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/ruby_xml_xpointer_context.h +18 -0
  63. data/test/sample_files/libxml-ruby-0.3.8/ext/xml/sax_parser_callbacks.inc +202 -0
  64. data/test/sample_files/syck-0.55/CHANGELOG +186 -0
  65. data/test/sample_files/syck-0.55/COPYING +54 -0
  66. data/test/sample_files/syck-0.55/Makefile +582 -0
  67. data/test/sample_files/syck-0.55/Makefile.am +5 -0
  68. data/test/sample_files/syck-0.55/Makefile.in +582 -0
  69. data/test/sample_files/syck-0.55/README +105 -0
  70. data/test/sample_files/syck-0.55/README.BYTECODE +484 -0
  71. data/test/sample_files/syck-0.55/README.EXT +444 -0
  72. data/test/sample_files/syck-0.55/RELEASE +123 -0
  73. data/test/sample_files/syck-0.55/TODO +25 -0
  74. data/test/sample_files/syck-0.55/aclocal.m4 +883 -0
  75. data/test/sample_files/syck-0.55/bootstrap +7 -0
  76. data/test/sample_files/syck-0.55/config.h +79 -0
  77. data/test/sample_files/syck-0.55/config.h.in +78 -0
  78. data/test/sample_files/syck-0.55/config.status +1197 -0
  79. data/test/sample_files/syck-0.55/config/README +14 -0
  80. data/test/sample_files/syck-0.55/config/depcomp +529 -0
  81. data/test/sample_files/syck-0.55/config/install-sh +323 -0
  82. data/test/sample_files/syck-0.55/config/missing +357 -0
  83. data/test/sample_files/syck-0.55/configure +6728 -0
  84. data/test/sample_files/syck-0.55/configure.in +36 -0
  85. data/test/sample_files/syck-0.55/ext/ruby/CHANGELOG +303 -0
  86. data/test/sample_files/syck-0.55/ext/ruby/README +400 -0
  87. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/MANIFEST +1 -0
  88. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/bytecode.c +1170 -0
  89. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/emitter.c +1224 -0
  90. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/extconf.rb +10 -0
  91. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.c +1894 -0
  92. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/gram.h +79 -0
  93. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/handler.c +174 -0
  94. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/implicit.c +2989 -0
  95. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/mkrf.log +1 -0
  96. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/node.c +407 -0
  97. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/rubyext.c +2385 -0
  98. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.c +504 -0
  99. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/syck.h +458 -0
  100. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/token.c +2707 -0
  101. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yaml2byte.c +250 -0
  102. data/test/sample_files/syck-0.55/ext/ruby/ext/syck/yamlbyte.h +170 -0
  103. data/test/sample_files/syck-0.55/ext/ruby/install.rb +1022 -0
  104. data/test/sample_files/syck-0.55/ext/ruby/lib/okay.rb +161 -0
  105. data/test/sample_files/syck-0.55/ext/ruby/lib/okay/news.rb +69 -0
  106. data/test/sample_files/syck-0.55/ext/ruby/lib/okay/rpc.rb +434 -0
  107. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml.rb +436 -0
  108. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/baseemitter.rb +247 -0
  109. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/basenode.rb +216 -0
  110. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/compat.rb +26 -0
  111. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/constants.rb +45 -0
  112. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/dbm.rb +111 -0
  113. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/emitter.rb +107 -0
  114. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/encoding.rb +33 -0
  115. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/error.rb +34 -0
  116. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/rubytypes.rb +438 -0
  117. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/store.rb +29 -0
  118. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stream.rb +40 -0
  119. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/stringio.rb +83 -0
  120. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/syck.rb +19 -0
  121. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/tag.rb +86 -0
  122. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/types.rb +188 -0
  123. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/yamlnode.rb +54 -0
  124. data/test/sample_files/syck-0.55/ext/ruby/lib/yaml/ypath.rb +52 -0
  125. data/test/sample_files/syck-0.55/ext/ruby/lib/yod.rb +1168 -0
  126. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-modules.rb +27 -0
  127. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-sample.rb +336 -0
  128. data/test/sample_files/syck-0.55/ext/ruby/samples/okayNews-validate.rb +341 -0
  129. data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-client.rb +51 -0
  130. data/test/sample_files/syck-0.55/ext/ruby/samples/okayRpc-server.rb +85 -0
  131. data/test/sample_files/syck-0.55/ext/ruby/samples/yaml-sortHashKeys.rb +128 -0
  132. data/test/sample_files/syck-0.55/ext/ruby/tests/basic.rb +1653 -0
  133. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsAnchorAlias.yml +51 -0
  134. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBasicTests.yml +282 -0
  135. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockMapping.yml +78 -0
  136. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsBlockSequence.yml +0 -0
  137. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsDocumentSeparator.yml +102 -0
  138. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsErrorTests.yml +23 -0
  139. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFlowCollections.yml +73 -0
  140. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsFoldedScalars.yml +215 -0
  141. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsMapInSeq.yml +0 -0
  142. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsNullsAndEmpties.yml +66 -0
  143. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsRubyTests.yml +182 -0
  144. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsSpecificationExamples.yml +2699 -0
  145. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsTypeTransfers.yml +265 -0
  146. data/test/sample_files/syck-0.55/ext/ruby/yts/YtsYpath.yml +221 -0
  147. data/test/sample_files/syck-0.55/ext/ruby/yts/cookbook.rb +159 -0
  148. data/test/sample_files/syck-0.55/ext/ruby/yts/index.yml +10 -0
  149. data/test/sample_files/syck-0.55/ext/ruby/yts/yts.rb +193 -0
  150. data/test/sample_files/syck-0.55/lib/Makefile +497 -0
  151. data/test/sample_files/syck-0.55/lib/Makefile.am +27 -0
  152. data/test/sample_files/syck-0.55/lib/Makefile.in +497 -0
  153. data/test/sample_files/syck-0.55/lib/bytecode.c +1170 -0
  154. data/test/sample_files/syck-0.55/lib/bytecode.re +525 -0
  155. data/test/sample_files/syck-0.55/lib/emitter.c +1224 -0
  156. data/test/sample_files/syck-0.55/lib/gram.c +1894 -0
  157. data/test/sample_files/syck-0.55/lib/gram.h +79 -0
  158. data/test/sample_files/syck-0.55/lib/gram.output +2005 -0
  159. data/test/sample_files/syck-0.55/lib/gram.y +481 -0
  160. data/test/sample_files/syck-0.55/lib/handler.c +174 -0
  161. data/test/sample_files/syck-0.55/lib/implicit.c +2989 -0
  162. data/test/sample_files/syck-0.55/lib/implicit.re +206 -0
  163. data/test/sample_files/syck-0.55/lib/node.c +407 -0
  164. data/test/sample_files/syck-0.55/lib/syck.c +504 -0
  165. data/test/sample_files/syck-0.55/lib/syck.h +458 -0
  166. data/test/sample_files/syck-0.55/lib/syck_st.c +577 -0
  167. data/test/sample_files/syck-0.55/lib/syck_st.h +46 -0
  168. data/test/sample_files/syck-0.55/lib/token.c +2707 -0
  169. data/test/sample_files/syck-0.55/lib/token.re +1139 -0
  170. data/test/sample_files/syck-0.55/lib/yaml2byte.c +250 -0
  171. data/test/sample_files/syck-0.55/lib/yamlbyte.h +170 -0
  172. data/test/sample_files/syck-0.55/stamp-h1 +1 -0
  173. data/test/sample_files/syck-0.55/tests/Basic.c +141 -0
  174. data/test/sample_files/syck-0.55/tests/CuTest.c +294 -0
  175. data/test/sample_files/syck-0.55/tests/CuTest.h +84 -0
  176. data/test/sample_files/syck-0.55/tests/Emit.c +87 -0
  177. data/test/sample_files/syck-0.55/tests/Makefile +480 -0
  178. data/test/sample_files/syck-0.55/tests/Makefile.am +13 -0
  179. data/test/sample_files/syck-0.55/tests/Makefile.in +480 -0
  180. data/test/sample_files/syck-0.55/tests/Parse.c +208 -0
  181. data/test/sample_files/syck-0.55/tests/YTS.c +2310 -0
  182. data/test/sample_files/syck-0.55/tests/YTS.c.erb +326 -0
  183. data/test/sample_files/syck-0.55/tests/YTS.c.rb +44 -0
  184. data/test/test_availability.rb +68 -0
  185. data/test/test_generator.rb +74 -0
  186. metadata +252 -0
@@ -0,0 +1,31 @@
1
+ /* $Id: ruby_xml_parser.h,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_PARSER__
6
+ #define __RUBY_XML_PARSER__
7
+
8
+ #define MAX_LIBXML_FEATURES_LEN 50
9
+
10
+ extern int ruby_xml_parser_count;
11
+ extern VALUE cXMLParser;
12
+ extern VALUE eXMLParserParseError;
13
+
14
+ typedef struct ruby_xml_parser {
15
+ VALUE ctxt;
16
+ int parsed;
17
+ void *data;
18
+ int data_type;
19
+ } ruby_xml_parser;
20
+
21
+ VALUE ruby_xml_parser_default_load_external_dtd_set(VALUE class, VALUE bool);
22
+ VALUE ruby_xml_parser_default_substitute_entities_set(VALUE class, VALUE bool);
23
+ VALUE ruby_xml_parser_features(VALUE self);
24
+ VALUE ruby_xml_parser_filename_get(VALUE self);
25
+ VALUE ruby_xml_parser_filename_set(VALUE self, VALUE filename);
26
+ VALUE ruby_xml_parser_new(VALUE class);
27
+ VALUE ruby_xml_parser_parse(VALUE self);
28
+ VALUE ruby_xml_parser_str_get(VALUE self);
29
+ VALUE ruby_xml_parser_str_set(VALUE self, VALUE str);
30
+
31
+ #endif
@@ -0,0 +1,715 @@
1
+ /* $Id: ruby_xml_parser_context.c,v 1.1 2006/02/21 20:40:16 roscopeco Exp $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "libxml.h"
6
+ #include "ruby_xml_parser_context.h"
7
+
8
+ /* TODO:
9
+ *
10
+ * *) xmlParserInput class/structure
11
+ * *) errNo and mappings
12
+ * *) validity context
13
+ * *) record_info or stats class/structure
14
+ * *) xmlParserNodeInfoSeq
15
+ * *) xmlParserInputState
16
+ */
17
+ VALUE cXMLParserContext;
18
+
19
+ /*
20
+ * call-seq:
21
+ * context.data_directory => "dir"
22
+ *
23
+ * Obtain the data directory associated with this context.
24
+ */
25
+ VALUE
26
+ ruby_xml_parser_context_data_directory_get(VALUE self) {
27
+ ruby_xml_parser_context *rxpc;
28
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
29
+
30
+ if (rxpc->ctxt->directory == NULL)
31
+ return(Qnil);
32
+ else
33
+ return(rb_str_new2(rxpc->ctxt->directory));
34
+ }
35
+
36
+
37
+ /*
38
+ * call-seq:
39
+ * context.depth => num
40
+ *
41
+ * Obtain the depth of this context.
42
+ */
43
+ VALUE
44
+ ruby_xml_parser_context_depth_get(VALUE self) {
45
+ ruby_xml_parser_context *rxpc;
46
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
47
+
48
+ return(INT2NUM(rxpc->ctxt->depth));
49
+ }
50
+
51
+
52
+ /*
53
+ * call-seq:
54
+ * context.disable_sax? => (true|false)
55
+ *
56
+ * Determine whether SAX-based processing is disabled
57
+ * in this context.
58
+ */
59
+ VALUE
60
+ ruby_xml_parser_context_disable_sax_q(VALUE self) {
61
+ ruby_xml_parser_context *rxpc;
62
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
63
+
64
+ if (rxpc->ctxt->disableSAX)
65
+ return(Qtrue);
66
+ else
67
+ return(Qfalse);
68
+ }
69
+
70
+
71
+ /*
72
+ * call-seq:
73
+ * context.doc => document
74
+ *
75
+ * Obtain the +XML::Document+ associated with this context.
76
+ */
77
+ VALUE
78
+ ruby_xml_parser_context_doc_get(VALUE self) {
79
+ ruby_xml_parser_context *rxpc;
80
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
81
+
82
+ if (rxpc->ctxt->myDoc == NULL)
83
+ return(Qnil);
84
+
85
+ return(ruby_xml_document_new4(cXMLDocument, rxpc->ctxt->myDoc));
86
+ }
87
+
88
+
89
+ /*
90
+ * call-seq:
91
+ * context.docbook? => (true|false)
92
+ *
93
+ * Determine whether this is a docbook context.
94
+ */
95
+ VALUE
96
+ ruby_xml_parser_context_docbook_q(VALUE self) {
97
+ ruby_xml_parser_context *rxpc;
98
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
99
+
100
+ if (rxpc->ctxt->html == 2) // TODO check this
101
+ return(Qtrue);
102
+ else
103
+ return(Qfalse);
104
+ }
105
+
106
+
107
+ /*
108
+ * call-seq:
109
+ * context.encoding => "encoding"
110
+ *
111
+ * Obtain the character encoding identifier used in
112
+ * this context.
113
+ */
114
+ VALUE
115
+ ruby_xml_parser_context_encoding_get(VALUE self) {
116
+ ruby_xml_parser_context *rxpc;
117
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
118
+
119
+ if (rxpc->ctxt->encoding == NULL)
120
+ return(Qnil);
121
+ else
122
+ return(rb_str_new2((const char*)rxpc->ctxt->encoding));
123
+ }
124
+
125
+
126
+ /*
127
+ * call-seq:
128
+ * context.errno => num
129
+ *
130
+ * Obtain the last-error number in this context.
131
+ */
132
+ VALUE
133
+ ruby_xml_parser_context_errno_get(VALUE self) {
134
+ ruby_xml_parser_context *rxpc;
135
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
136
+
137
+ return(INT2NUM(rxpc->ctxt->errNo));
138
+ }
139
+
140
+
141
+ void
142
+ ruby_xml_parser_context_free(ruby_xml_parser_context *rxpc) {
143
+ if (rxpc->ctxt != NULL && !rxpc->is_ptr) {
144
+ xmlFreeParserCtxt(rxpc->ctxt);
145
+ ruby_xml_parser_count--;
146
+ rxpc->ctxt = NULL;
147
+ }
148
+
149
+ if (ruby_xml_parser_count == 0)
150
+ xmlCleanupParser();
151
+
152
+ free(rxpc);
153
+ }
154
+
155
+
156
+ /*
157
+ * call-seq:
158
+ * context.html? => (true|false)
159
+ *
160
+ * Determine whether this is an html context.
161
+ */
162
+ VALUE
163
+ ruby_xml_parser_context_html_q(VALUE self) {
164
+ ruby_xml_parser_context *rxpc;
165
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
166
+
167
+ if (rxpc->ctxt->html == 1)
168
+ return(Qtrue);
169
+ else
170
+ return(Qfalse);
171
+ }
172
+
173
+
174
+ /*
175
+ * call-seq:
176
+ * context.max_num_streams => num
177
+ *
178
+ * Obtain the limit on the number of IO streams opened in
179
+ * this context.
180
+ */
181
+ VALUE
182
+ ruby_xml_parser_context_io_max_num_streams_get(VALUE self) {
183
+ // TODO alias to max_streams and dep this?
184
+ ruby_xml_parser_context *rxpc;
185
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
186
+
187
+ return(INT2NUM(rxpc->ctxt->inputMax));
188
+ }
189
+
190
+
191
+ /*
192
+ * call-seq:
193
+ * context.num_streams => "dir"
194
+ *
195
+ * Obtain the actual number of IO streams in this
196
+ * context.
197
+ */
198
+ VALUE
199
+ ruby_xml_parser_context_io_num_streams_get(VALUE self) {
200
+ ruby_xml_parser_context *rxpc;
201
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
202
+
203
+ return(INT2NUM(rxpc->ctxt->inputNr));
204
+ }
205
+
206
+
207
+ /*
208
+ * call-seq:
209
+ * context.keep_blanks? => (true|false)
210
+ *
211
+ * Determine whether parsers in this context retain
212
+ * whitespace.
213
+ */
214
+ VALUE
215
+ ruby_xml_parser_context_keep_blanks_q(VALUE self) {
216
+ ruby_xml_parser_context *rxpc;
217
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
218
+
219
+ if (rxpc->ctxt->keepBlanks)
220
+ return(Qtrue);
221
+ else
222
+ return(Qfalse);
223
+ }
224
+
225
+
226
+ /*
227
+ * call-seq:
228
+ * context.name_depth => num
229
+ *
230
+ * Obtain the name depth for this context.
231
+ */
232
+ VALUE
233
+ ruby_xml_parser_context_name_depth_get(VALUE self) {
234
+ ruby_xml_parser_context *rxpc;
235
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
236
+
237
+ return(INT2NUM(rxpc->ctxt->nameNr));
238
+ }
239
+
240
+
241
+ /*
242
+ * call-seq:
243
+ * context.name_depth_max => num
244
+ *
245
+ * Obtain the maximum name depth for this context.
246
+ */
247
+ VALUE
248
+ ruby_xml_parser_context_name_depth_max_get(VALUE self) {
249
+ ruby_xml_parser_context *rxpc;
250
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
251
+
252
+ return(INT2NUM(rxpc->ctxt->nameMax));
253
+ }
254
+
255
+
256
+ /*
257
+ * call-seq:
258
+ * context.name_node => "name"
259
+ *
260
+ * Obtain the name node for this context.
261
+ */
262
+ VALUE
263
+ ruby_xml_parser_context_name_node_get(VALUE self) {
264
+ ruby_xml_parser_context *rxpc;
265
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
266
+
267
+ if (rxpc->ctxt->name == NULL)
268
+ return(Qnil);
269
+ else
270
+ return(rb_str_new2((const char*)rxpc->ctxt->name));
271
+ }
272
+
273
+
274
+ /*
275
+ * call-seq:
276
+ * context.name_tab => ["name", ..., "name"]
277
+ *
278
+ * Obtain the name table for this context.
279
+ */
280
+ VALUE
281
+ ruby_xml_parser_context_name_tab_get(VALUE self) {
282
+ int i;
283
+ ruby_xml_parser_context *rxpc;
284
+ VALUE tab_ary;
285
+
286
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
287
+
288
+ if (rxpc->ctxt->nameTab == NULL)
289
+ return(Qnil);
290
+
291
+ tab_ary = rb_ary_new();
292
+
293
+ for (i = (rxpc->ctxt->nameNr - 1); i >= 0; i--) {
294
+ if (rxpc->ctxt->nameTab[i] == NULL)
295
+ continue;
296
+ else
297
+ rb_ary_push(tab_ary, rb_str_new2((const char*)rxpc->ctxt->nameTab[i]));
298
+ }
299
+
300
+ return(tab_ary);
301
+ }
302
+
303
+
304
+ /*
305
+ * call-seq:
306
+ * context.node_depth => num
307
+ *
308
+ * Obtain the node depth for this context.
309
+ */
310
+ VALUE
311
+ ruby_xml_parser_context_node_depth_get(VALUE self) {
312
+ ruby_xml_parser_context *rxpc;
313
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
314
+
315
+ return(INT2NUM(rxpc->ctxt->nodeNr));
316
+ }
317
+
318
+
319
+ /*
320
+ * call-seq:
321
+ * context.node => node
322
+ *
323
+ * Obtain the root node of this context.
324
+ */
325
+ VALUE
326
+ ruby_xml_parser_context_node_get(VALUE self) {
327
+ ruby_xml_parser_context *rxpc;
328
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
329
+
330
+ if (rxpc->ctxt->node == NULL)
331
+ return(Qnil);
332
+ else
333
+ return(ruby_xml_node_new2(cXMLNode,
334
+ ruby_xml_document_new(cXMLDocument, rxpc->ctxt->myDoc),
335
+ rxpc->ctxt->node));
336
+ }
337
+
338
+
339
+ /*
340
+ * call-seq:
341
+ * context.node_depth_max => num
342
+ *
343
+ * Obtain the maximum node depth for this context.
344
+ */
345
+ VALUE
346
+ ruby_xml_parser_context_node_depth_max_get(VALUE self) {
347
+ ruby_xml_parser_context *rxpc;
348
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
349
+
350
+ return(INT2NUM(rxpc->ctxt->nodeMax));
351
+ }
352
+
353
+
354
+ /*
355
+ * call-seq:
356
+ * context.num_chars => num
357
+ *
358
+ * Obtain the number of characters in this context.
359
+ */
360
+ VALUE
361
+ ruby_xml_parser_context_num_chars_get(VALUE self) {
362
+ ruby_xml_parser_context *rxpc;
363
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
364
+
365
+ return(LONG2NUM(rxpc->ctxt->nbChars));
366
+ }
367
+
368
+
369
+ VALUE
370
+ ruby_xml_parser_context_new(VALUE class, xmlParserCtxtPtr ctxt) {
371
+ ruby_xml_parser_context *rxpc;
372
+
373
+ rxpc = ALLOC(ruby_xml_parser_context);
374
+ ruby_xml_parser_count++;
375
+
376
+ rxpc->ctxt = ctxt;
377
+ rxpc->is_ptr = 0;
378
+ return(Data_Wrap_Struct(class, 0, ruby_xml_parser_context_free, rxpc));
379
+ }
380
+
381
+
382
+ VALUE
383
+ ruby_xml_parser_context_new2(VALUE class) {
384
+ return(ruby_xml_parser_context_new(class, NULL));
385
+ }
386
+
387
+
388
+ VALUE
389
+ ruby_xml_parser_context_new3() {
390
+ return(ruby_xml_parser_context_new2(cXMLParserContext));
391
+ }
392
+
393
+
394
+ /*
395
+ * call-seq:
396
+ * context.replace_entities? => (true|false)
397
+ *
398
+ * Determine whether external entity replacement is enabled in this
399
+ * context.
400
+ */
401
+ VALUE
402
+ ruby_xml_parser_context_replace_entities_q(VALUE self) {
403
+ ruby_xml_parser_context *rxpc;
404
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
405
+
406
+ if (rxpc->ctxt->replaceEntities)
407
+ return(Qtrue);
408
+ else
409
+ return(Qfalse);
410
+ }
411
+
412
+
413
+ /*
414
+ * call-seq:
415
+ * context.replace_entities = true|false
416
+ *
417
+ * Control whether external entity replacement is enabled in this
418
+ * context.
419
+ */
420
+ VALUE
421
+ ruby_xml_parser_context_replace_entities_set(VALUE self, VALUE bool) {
422
+ ruby_xml_parser_context *rxpc;
423
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
424
+
425
+ if (TYPE(bool) == T_FALSE) {
426
+ rxpc->ctxt->replaceEntities = 0;
427
+ return(Qfalse);
428
+ } else {
429
+ rxpc->ctxt->replaceEntities = 1;
430
+ return(Qfalse);
431
+ }
432
+ }
433
+
434
+
435
+ /*
436
+ * call-seq:
437
+ * context.space_depth => num
438
+ *
439
+ * Obtain the space depth for this context.
440
+ */
441
+ VALUE
442
+ ruby_xml_parser_context_space_depth_get(VALUE self) {
443
+ ruby_xml_parser_context *rxpc;
444
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
445
+
446
+ return(INT2NUM(rxpc->ctxt->spaceNr));
447
+ }
448
+
449
+
450
+ /*
451
+ * call-seq:
452
+ * context.space_depth => num
453
+ *
454
+ * Obtain the maximum space depth for this context.
455
+ */
456
+ VALUE
457
+ ruby_xml_parser_context_space_depth_max_get(VALUE self) {
458
+ ruby_xml_parser_context *rxpc;
459
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
460
+
461
+ return(INT2NUM(rxpc->ctxt->spaceMax));
462
+ }
463
+
464
+
465
+ /*
466
+ * call-seq:
467
+ * context.subset_external? => (true|false)
468
+ *
469
+ * Determine whether this context is a subset of an
470
+ * external context.
471
+ */
472
+ VALUE
473
+ ruby_xml_parser_context_subset_external_q(VALUE self) {
474
+ ruby_xml_parser_context *rxpc;
475
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
476
+
477
+ if (rxpc->ctxt->inSubset == 2)
478
+ return(Qtrue);
479
+ else
480
+ return(Qfalse);
481
+ }
482
+
483
+
484
+ /*
485
+ * call-seq:
486
+ * context.subset_internal? => (true|false)
487
+ *
488
+ * Determine whether this context is a subset of an
489
+ * internal context.
490
+ */
491
+ VALUE
492
+ ruby_xml_parser_context_subset_internal_q(VALUE self) {
493
+ ruby_xml_parser_context *rxpc;
494
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
495
+
496
+ if (rxpc->ctxt->inSubset == 1)
497
+ return(Qtrue);
498
+ else
499
+ return(Qfalse);
500
+ }
501
+
502
+
503
+ /*
504
+ * call-seq:
505
+ * context.subset_name => "name"
506
+ *
507
+ * Obtain this context's subset name (valid only if
508
+ * either of subset_external? or subset_internal?
509
+ * is true).
510
+ */
511
+ VALUE
512
+ ruby_xml_parser_context_subset_name_get(VALUE self) {
513
+ ruby_xml_parser_context *rxpc;
514
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
515
+
516
+ if (rxpc->ctxt->intSubName == NULL)
517
+ return(Qnil);
518
+ else
519
+ return(rb_str_new2((const char*)rxpc->ctxt->intSubName));
520
+ }
521
+
522
+
523
+ /*
524
+ * call-seq:
525
+ * context.subset_external_uri => "uri"
526
+ *
527
+ * Obtain this context's external subset URI. (valid only if
528
+ * either of subset_external? or subset_internal?
529
+ * is true).
530
+ */
531
+ VALUE
532
+ ruby_xml_parser_context_subset_external_uri_get(VALUE self) {
533
+ ruby_xml_parser_context *rxpc;
534
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
535
+
536
+ if (rxpc->ctxt->extSubURI == NULL)
537
+ return(Qnil);
538
+ else
539
+ return(rb_str_new2((const char*)rxpc->ctxt->extSubURI));
540
+ }
541
+
542
+
543
+ /*
544
+ * call-seq:
545
+ * context.subset_external_system_id => "system_id"
546
+ *
547
+ * Obtain this context's external subset system identifier.
548
+ * (valid only if either of subset_external? or subset_internal?
549
+ * is true).
550
+ */
551
+ VALUE
552
+ ruby_xml_parser_context_subset_external_system_id_get(VALUE self) {
553
+ ruby_xml_parser_context *rxpc;
554
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
555
+
556
+ if (rxpc->ctxt->extSubSystem == NULL)
557
+ return(Qnil);
558
+ else
559
+ return(rb_str_new2((const char*)rxpc->ctxt->extSubSystem));
560
+ }
561
+
562
+
563
+ /*
564
+ * call-seq:
565
+ * context.standalone? => (true|false)
566
+ *
567
+ * Determine whether this is a standalone context.
568
+ */
569
+ VALUE
570
+ ruby_xml_parser_context_standalone_q(VALUE self) {
571
+ ruby_xml_parser_context *rxpc;
572
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
573
+
574
+ if (rxpc->ctxt->standalone)
575
+ return(Qtrue);
576
+ else
577
+ return(Qfalse);
578
+ }
579
+
580
+
581
+ /*
582
+ * call-seq:
583
+ * context.stats? => (true|false)
584
+ *
585
+ * Determine whether this context maintains statistics.
586
+ */
587
+ VALUE
588
+ ruby_xml_parser_context_stats_q(VALUE self) {
589
+ ruby_xml_parser_context *rxpc;
590
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
591
+
592
+ if (rxpc->ctxt->record_info)
593
+ return(Qtrue);
594
+ else
595
+ return(Qfalse);
596
+ }
597
+
598
+
599
+ /*
600
+ * call-seq:
601
+ * context.valid? => (true|false)
602
+ *
603
+ * Determine whether this context is valid.
604
+ */
605
+ VALUE
606
+ ruby_xml_parser_context_valid_q(VALUE self) {
607
+ ruby_xml_parser_context *rxpc;
608
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
609
+
610
+ if (rxpc->ctxt->valid)
611
+ return(Qtrue);
612
+ else
613
+ return(Qfalse);
614
+ }
615
+
616
+
617
+ /*
618
+ * call-seq:
619
+ * context.validate? => (true|false)
620
+ *
621
+ * Determine whether validation is enabled in this context.
622
+ */
623
+ VALUE
624
+ ruby_xml_parser_context_validate_q(VALUE self) {
625
+ ruby_xml_parser_context *rxpc;
626
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
627
+
628
+ if (rxpc->ctxt->validate)
629
+ return(Qtrue);
630
+ else
631
+ return(Qfalse);
632
+ }
633
+
634
+
635
+ /*
636
+ * call-seq:
637
+ * context.version => "version"
638
+ *
639
+ * Obtain this context's version identifier.
640
+ */
641
+ VALUE
642
+ ruby_xml_parser_context_version_get(VALUE self) {
643
+ ruby_xml_parser_context *rxpc;
644
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
645
+
646
+ if (rxpc->ctxt->version == NULL)
647
+ return(Qnil);
648
+ else
649
+ return(rb_str_new2((const char*)rxpc->ctxt->version));
650
+ }
651
+
652
+
653
+ /*
654
+ * call-seq:
655
+ * context.well_formed? => (true|false)
656
+ *
657
+ * Determine whether this context contains well-formed XML.
658
+ */
659
+ VALUE
660
+ ruby_xml_parser_context_well_formed_q(VALUE self) {
661
+ ruby_xml_parser_context *rxpc;
662
+ Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
663
+
664
+ if (rxpc->ctxt->wellFormed)
665
+ return(Qtrue);
666
+ else
667
+ return(Qfalse);
668
+ }
669
+
670
+
671
+ // Rdoc needs to know
672
+ #ifdef RDOC_NEVER_DEFINED
673
+ mXML = rb_define_module("XML");
674
+ cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
675
+ #endif
676
+
677
+ void
678
+ ruby_init_xml_parser_context(void) {
679
+ cXMLParserContext = rb_define_class_under(cXMLParser, "Context", rb_cObject);
680
+
681
+ rb_define_method(cXMLParserContext, "data_directory", ruby_xml_parser_context_data_directory_get, 0);
682
+ rb_define_method(cXMLParserContext, "depth", ruby_xml_parser_context_depth_get, 0);
683
+ rb_define_method(cXMLParserContext, "disable_sax?", ruby_xml_parser_context_disable_sax_q, 0);
684
+ rb_define_method(cXMLParserContext, "doc", ruby_xml_parser_context_doc_get, 0);
685
+ rb_define_method(cXMLParserContext, "docbook?", ruby_xml_parser_context_docbook_q, 0);
686
+ rb_define_method(cXMLParserContext, "encoding", ruby_xml_parser_context_encoding_get, 0);
687
+ rb_define_method(cXMLParserContext, "errno", ruby_xml_parser_context_errno_get, 0);
688
+ rb_define_method(cXMLParserContext, "html?", ruby_xml_parser_context_html_q, 0);
689
+ rb_define_method(cXMLParserContext, "io_max_num_streams", ruby_xml_parser_context_io_max_num_streams_get, 0);
690
+ rb_define_method(cXMLParserContext, "io_num_streams", ruby_xml_parser_context_io_num_streams_get, 0);
691
+ rb_define_method(cXMLParserContext, "keep_blanks?", ruby_xml_parser_context_keep_blanks_q, 0);
692
+ rb_define_method(cXMLParserContext, "name_node", ruby_xml_parser_context_name_node_get, 0);
693
+ rb_define_method(cXMLParserContext, "name_depth", ruby_xml_parser_context_name_depth_get, 0);
694
+ rb_define_method(cXMLParserContext, "name_depth_max", ruby_xml_parser_context_name_depth_max_get, 0);
695
+ rb_define_method(cXMLParserContext, "name_tab", ruby_xml_parser_context_name_tab_get, 0);
696
+ rb_define_method(cXMLParserContext, "node", ruby_xml_parser_context_node_get, 0);
697
+ rb_define_method(cXMLParserContext, "node_depth", ruby_xml_parser_context_node_depth_get, 0);
698
+ rb_define_method(cXMLParserContext, "node_depth_max", ruby_xml_parser_context_node_depth_max_get, 0);
699
+ rb_define_method(cXMLParserContext, "num_chars", ruby_xml_parser_context_num_chars_get, 0);
700
+ rb_define_method(cXMLParserContext, "replace_entities?", ruby_xml_parser_context_replace_entities_q, 0);
701
+ rb_define_method(cXMLParserContext, "replace_entities=", ruby_xml_parser_context_replace_entities_set, 1);
702
+ rb_define_method(cXMLParserContext, "space_depth", ruby_xml_parser_context_space_depth_get, 0);
703
+ rb_define_method(cXMLParserContext, "space_depth_max", ruby_xml_parser_context_space_depth_max_get, 0);
704
+ rb_define_method(cXMLParserContext, "subset_external?", ruby_xml_parser_context_subset_external_q, 0);
705
+ rb_define_method(cXMLParserContext, "subset_external_system_id", ruby_xml_parser_context_subset_external_system_id_get, 0);
706
+ rb_define_method(cXMLParserContext, "subset_external_uri", ruby_xml_parser_context_subset_name_get, 0);
707
+ rb_define_method(cXMLParserContext, "subset_internal?", ruby_xml_parser_context_subset_internal_q, 0);
708
+ rb_define_method(cXMLParserContext, "subset_internal_name", ruby_xml_parser_context_subset_name_get, 0);
709
+ rb_define_method(cXMLParserContext, "stats?", ruby_xml_parser_context_stats_q, 0);
710
+ rb_define_method(cXMLParserContext, "standalone?", ruby_xml_parser_context_standalone_q, 0);
711
+ rb_define_method(cXMLParserContext, "valid", ruby_xml_parser_context_valid_q, 0);
712
+ rb_define_method(cXMLParserContext, "validate?", ruby_xml_parser_context_validate_q, 0);
713
+ rb_define_method(cXMLParserContext, "version", ruby_xml_parser_context_version_get, 0);
714
+ rb_define_method(cXMLParserContext, "well_formed?", ruby_xml_parser_context_well_formed_q, 0);
715
+ }