ox-bundlecachetest 2.14.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +751 -0
  3. data/LICENSE +21 -0
  4. data/README.md +351 -0
  5. data/ext/ox/attr.h +78 -0
  6. data/ext/ox/base64.c +105 -0
  7. data/ext/ox/base64.h +18 -0
  8. data/ext/ox/buf.h +162 -0
  9. data/ext/ox/builder.c +948 -0
  10. data/ext/ox/cache.c +351 -0
  11. data/ext/ox/cache.h +21 -0
  12. data/ext/ox/cache8.c +106 -0
  13. data/ext/ox/cache8.h +23 -0
  14. data/ext/ox/dump.c +1260 -0
  15. data/ext/ox/err.c +46 -0
  16. data/ext/ox/err.h +36 -0
  17. data/ext/ox/extconf.rb +47 -0
  18. data/ext/ox/gen_load.c +342 -0
  19. data/ext/ox/hash_load.c +309 -0
  20. data/ext/ox/helper.h +84 -0
  21. data/ext/ox/intern.c +157 -0
  22. data/ext/ox/intern.h +25 -0
  23. data/ext/ox/obj_load.c +809 -0
  24. data/ext/ox/ox.c +1649 -0
  25. data/ext/ox/ox.h +245 -0
  26. data/ext/ox/parse.c +1197 -0
  27. data/ext/ox/sax.c +1570 -0
  28. data/ext/ox/sax.h +69 -0
  29. data/ext/ox/sax_as.c +270 -0
  30. data/ext/ox/sax_buf.c +209 -0
  31. data/ext/ox/sax_buf.h +204 -0
  32. data/ext/ox/sax_hint.c +207 -0
  33. data/ext/ox/sax_hint.h +40 -0
  34. data/ext/ox/sax_stack.h +113 -0
  35. data/ext/ox/slotcache.c +158 -0
  36. data/ext/ox/slotcache.h +19 -0
  37. data/ext/ox/special.c +390 -0
  38. data/ext/ox/special.h +14 -0
  39. data/ext/ox/type.h +39 -0
  40. data/lib/ox/bag.rb +103 -0
  41. data/lib/ox/cdata.rb +10 -0
  42. data/lib/ox/comment.rb +11 -0
  43. data/lib/ox/doctype.rb +11 -0
  44. data/lib/ox/document.rb +28 -0
  45. data/lib/ox/element.rb +464 -0
  46. data/lib/ox/error.rb +25 -0
  47. data/lib/ox/hasattrs.rb +54 -0
  48. data/lib/ox/instruct.rb +34 -0
  49. data/lib/ox/node.rb +23 -0
  50. data/lib/ox/raw.rb +12 -0
  51. data/lib/ox/sax.rb +97 -0
  52. data/lib/ox/version.rb +4 -0
  53. data/lib/ox/xmlrpc_adapter.rb +33 -0
  54. data/lib/ox.rb +79 -0
  55. metadata +128 -0
data/ext/ox/buf.h ADDED
@@ -0,0 +1,162 @@
1
+ /* buf.h
2
+ * Copyright (c) 2014, Peter Ohler
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions are met:
7
+ *
8
+ * - Redistributions of source code must retain the above copyright notice, this
9
+ * list of conditions and the following disclaimer.
10
+ *
11
+ * - Redistributions in binary form must reproduce the above copyright notice,
12
+ * this list of conditions and the following disclaimer in the documentation
13
+ * and/or other materials provided with the distribution.
14
+ *
15
+ * - Neither the name of Peter Ohler nor the names of its contributors may be
16
+ * used to endorse or promote products derived from this software without
17
+ * specific prior written permission.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ */
30
+
31
+ #ifndef OX_BUF_H
32
+ #define OX_BUF_H
33
+
34
+ #include <ruby.h>
35
+ #include <stdbool.h>
36
+ #include <unistd.h>
37
+
38
+ typedef struct _buf {
39
+ char *head;
40
+ char *end;
41
+ char *tail;
42
+ int fd;
43
+ bool err;
44
+ char base[16384];
45
+ } *Buf;
46
+
47
+ inline static void buf_init(Buf buf, int fd, long initial_size) {
48
+ if (sizeof(buf->base) < (size_t)initial_size) {
49
+ buf->head = ALLOC_N(char, initial_size);
50
+ buf->end = buf->head + initial_size - 1;
51
+ } else {
52
+ buf->head = buf->base;
53
+ buf->end = buf->base + sizeof(buf->base) - 1;
54
+ }
55
+ buf->tail = buf->head;
56
+ buf->fd = fd;
57
+ buf->err = false;
58
+ }
59
+
60
+ inline static void buf_reset(Buf buf) {
61
+ buf->head = buf->base;
62
+ buf->tail = buf->head;
63
+ }
64
+
65
+ inline static void buf_cleanup(Buf buf) {
66
+ if (buf->base != buf->head) {
67
+ free(buf->head);
68
+ }
69
+ }
70
+
71
+ inline static size_t buf_len(Buf buf) {
72
+ return buf->tail - buf->head;
73
+ }
74
+
75
+ inline static void buf_append_string(Buf buf, const char *s, size_t slen) {
76
+ if (buf->err) {
77
+ return;
78
+ }
79
+ if (buf->end <= buf->tail + slen) {
80
+ if (0 != buf->fd) {
81
+ size_t len = buf->tail - buf->head;
82
+
83
+ if (len != (size_t)write(buf->fd, buf->head, len)) {
84
+ buf->err = true;
85
+ return;
86
+ }
87
+ buf->tail = buf->head;
88
+ if (sizeof(buf->base) <= slen) {
89
+ if (slen != (size_t)write(buf->fd, s, slen)) {
90
+ buf->err = true;
91
+ return;
92
+ }
93
+ return;
94
+ }
95
+ } else {
96
+ size_t len = buf->end - buf->head;
97
+ size_t toff = buf->tail - buf->head;
98
+ size_t new_len = len + slen + len / 2;
99
+
100
+ if (buf->base == buf->head) {
101
+ buf->head = ALLOC_N(char, new_len);
102
+ memcpy(buf->head, buf->base, len);
103
+ } else {
104
+ REALLOC_N(buf->head, char, new_len);
105
+ }
106
+ buf->tail = buf->head + toff;
107
+ buf->end = buf->head + new_len - 2;
108
+ }
109
+ }
110
+ if (0 < slen) {
111
+ memcpy(buf->tail, s, slen);
112
+ }
113
+ buf->tail += slen;
114
+ }
115
+
116
+ inline static void buf_append(Buf buf, char c) {
117
+ if (buf->err) {
118
+ return;
119
+ }
120
+ if (buf->end <= buf->tail) {
121
+ if (0 != buf->fd) {
122
+ size_t len = buf->tail - buf->head;
123
+
124
+ if (len != (size_t)write(buf->fd, buf->head, len)) {
125
+ buf->err = true;
126
+ }
127
+ buf->tail = buf->head;
128
+ } else {
129
+ size_t len = buf->end - buf->head;
130
+ size_t toff = buf->tail - buf->head;
131
+ size_t new_len = len + len / 2;
132
+
133
+ if (buf->base == buf->head) {
134
+ buf->head = ALLOC_N(char, new_len);
135
+ memcpy(buf->head, buf->base, len);
136
+ } else {
137
+ REALLOC_N(buf->head, char, new_len);
138
+ }
139
+ buf->tail = buf->head + toff;
140
+ buf->end = buf->head + new_len - 2;
141
+ }
142
+ }
143
+ *buf->tail++ = c;
144
+ //*buf->tail = '\0'; // for debugging
145
+ }
146
+
147
+ inline static void buf_finish(Buf buf) {
148
+ if (buf->err) {
149
+ return;
150
+ }
151
+ if (0 != buf->fd) {
152
+ size_t len = buf->tail - buf->head;
153
+
154
+ if (0 < len && len != (size_t)write(buf->fd, buf->head, len)) {
155
+ buf->err = true;
156
+ }
157
+ fsync(buf->fd);
158
+ buf->tail = buf->head;
159
+ }
160
+ }
161
+
162
+ #endif /* OX_BUF_H */