Permalink
Browse files

initial checkin

  • Loading branch information...
1 parent ddb0352 commit b1a7937fbf949bb56a4db7029b77ab5d86c42d3a Peter Ohler committed Feb 9, 2011
Showing with 11,062 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +187 −0 ext/ox/Makefile
  3. +123 −0 ext/ox/base64.c
  4. +44 −0 ext/ox/base64.h
  5. BIN ext/ox/base64.o
  6. +148 −0 ext/ox/cache.c
  7. +43 −0 ext/ox/cache.h
  8. BIN ext/ox/cache.o
  9. +100 −0 ext/ox/cache16.z
  10. +69 −0 ext/ox/cache_test.c
  11. BIN ext/ox/cache_test.o
  12. +836 −0 ext/ox/dump.c
  13. BIN ext/ox/dump.o
  14. +7 −0 ext/ox/extconf.rb
  15. +175 −0 ext/ox/gen_load.c
  16. BIN ext/ox/gen_load.o
  17. +623 −0 ext/ox/obj_load.c
  18. BIN ext/ox/obj_load.o
  19. BIN ext/ox/ox.bundle
  20. +424 −0 ext/ox/ox.c
  21. +179 −0 ext/ox/ox.h
  22. BIN ext/ox/ox.o
  23. +602 −0 ext/ox/parse.c
  24. BIN ext/ox/parse.o
  25. +97 −0 lib/ox.rb
  26. +12 −0 lib/ox/cdata.rb
  27. +13 −0 lib/ox/comment.rb
  28. +13 −0 lib/ox/doctype.rb
  29. +20 −0 lib/ox/document.rb
  30. +67 −0 lib/ox/element.rb
  31. +24 −0 lib/ox/node.rb
  32. +55 −0 misc/load_cfg.rb
  33. +23 −0 notes
  34. +2,318 −0 test/Sample.graffle
  35. +17 −0 test/cache16_test.rb
  36. +17 −0 test/cache_test.rb
  37. +34 −0 test/files.rb
  38. +181 −0 test/func.rb
  39. +22 −0 test/gen_sample.rb
  40. +19 −0 test/obj_sample.rb
  41. +16 −0 test/ox/change.rb
  42. +21 −0 test/ox/dir.rb
  43. +39 −0 test/ox/doc.rb
  44. +33 −0 test/ox/file.rb
  45. +18 −0 test/ox/group.rb
  46. +18 −0 test/ox/hasprops.rb
  47. +14 −0 test/ox/layer.rb
  48. +22 −0 test/ox/line.rb
  49. +12 −0 test/ox/oval.rb
  50. +12 −0 test/ox/rect.rb
  51. +37 −0 test/ox/shape.rb
  52. +23 −0 test/ox/text.rb
  53. +193 −0 test/perf_gen.rb
  54. +97 −0 test/perf_mars.rb
  55. +199 −0 test/perf_obj.rb
  56. +88 −0 test/perf_pod.rb
  57. +80 −0 test/perf_write.rb
  58. BIN test/sample.marshal
  59. +62 −0 test/sample.rb
  60. +655 −0 test/sample.xml
  61. +70 −0 test/test.rb
  62. +3 −0 xml/attr.xml
  63. +4 −0 xml/comment.xml
  64. +2 −0 xml/empty.xml
  65. +37 −0 xml/env.xml
  66. +3 −0 xml/loner.xml
  67. +6 −0 xml/mixed.xml
  68. +10 −0 xml/nest.xml
  69. +5 −0 xml/sample.xml
  70. +1,012 −0 xml/wFractal.xml
  71. +1,239 −0 xml/wFractal_report.xml
  72. +453 −0 xml/wr.xml
  73. +18 −0 xml/zoo.xml
  74. +64 −0 xml/zoo2.xml
View
@@ -0,0 +1,5 @@
+ox-*.gem
+.DS_Store
+\#*\#
+.\#*
+*~
View
@@ -0,0 +1,187 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /Users/ohler/.rvm/rubies/ruby-1.9.2-p136/include/ruby-1.9.1
+hdrdir = /Users/ohler/.rvm/rubies/ruby-1.9.2-p136/include/ruby-1.9.1
+arch_hdrdir = /Users/ohler/.rvm/rubies/ruby-1.9.2-p136/include/ruby-1.9.1/$(arch)
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+prefix = $(DESTDIR)/Users/ohler/.rvm/rubies/ruby-1.9.2-p136
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitedir = $(rubylibprefix)/site_ruby
+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
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+archdir = $(rubylibdir)/$(arch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitearchdir = $(sitelibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
+OUTFLAG = -o
+COUTFLAG = -o
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3
+debugflags = -ggdb
+warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long
+CFLAGS = -fno-common $(cflags) -fno-common -pipe
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags) -Wall
+CXXFLAGS = $(CFLAGS) $(cxxflags)
+ldflags = -L. -L/usr/local/lib
+dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags)
+LDSHARED = $(CC) -dynamic -bundle
+LDSHAREDXX = $(CXX) -dynamic -bundle
+AR = ar
+EXEEXT =
+
+RUBY_BASE_NAME = ruby
+RUBY_INSTALL_NAME = ruby
+RUBY_SO_NAME = ruby.1.9.1
+arch = x86_64-darwin10.6.0
+sitearch = $(arch)
+ruby_version = 1.9.1
+ruby = /Users/ohler/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
+RUBY = $(ruby)
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = $(RUBY) -run -e rmdir -- -p
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(libdir)
+LIBPATH = -L. -L$(libdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout =
+extout_prefix =
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
+SRCS = base64.c cache.c cache_test.c dump.c gen_load.c obj_load.c ox.c parse.c
+OBJS = base64.o cache.o cache_test.o dump.o gen_load.o obj_load.o ox.o parse.o
+TARGET = ox
+DLLIB = $(TARGET).bundle
+EXTSTATIC =
+STATIC_LIB =
+
+BINDIR = $(bindir)
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
+ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(DLLIB)
+CLEANLIBS = $(TARGET).bundle
+CLEANOBJS = *.o *.bak
+
+all: $(DLLIB)
+static: $(STATIC_LIB)
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-rb
+
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-rb-default clean-rb
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean: clean distclean-so distclean-rb-default distclean-rb
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ @-$(RMDIRS) $(DISTCLEANDIRS)
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+ @-$(MAKEDIRS) $(@D)
+ $(INSTALL_PROG) $(DLLIB) $(@D)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+ $(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
+
+.cc.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.C.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.o:
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+$(DLLIB): $(OBJS) Makefile
+ @-$(RM) $(@)
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
View
@@ -0,0 +1,123 @@
+/* base64.c
+ * Copyright (c) 2011, Peter Ohler
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * - 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.
+ *
+ * - Neither the name of Peter Ohler 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
+ */
+
+#include <stdlib.h>
+
+#include "base64.h"
+
+static char digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+// invalid or terminating characters are set to 'X' or \x58
+static u_char s_digits[256] = "\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x3E\x58\x58\x58\x3F\
+\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x58\x58\x58\x58\x58\x58\
+\x58\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\
+\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x58\x58\x58\x58\x58\
+\x58\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\
+\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\
+\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58\x58";
+
+void
+to_base64(const u_char *src, int len, char *b64) {
+ const u_char *end3;
+ int len3 = len % 3;
+ u_char b1, b2, b3;
+
+ end3 = src + (len - len3);
+ while (src < end3) {
+ b1 = *src++;
+ b2 = *src++;
+ b3 = *src++;
+ *b64++ = digits[b1 >> 2];
+ *b64++ = digits[((b1 & 0x03) << 4) | (b2 >> 4)];
+ *b64++ = digits[((b2 & 0x0F) << 2) | (b3 >> 6)];
+ *b64++ = digits[b3 & 0x3F];
+ }
+ if (1 == len3) {
+ b1 = *src++;
+ *b64++ = digits[b1 >> 2];
+ *b64++ = digits[(b1 & 0x03) << 4];
+ *b64++ = '=';
+ *b64++ = '=';
+ } else if (2 == len3) {
+ b1 = *src++;
+ b2 = *src++;
+ *b64++ = digits[b1 >> 2];
+ *b64++ = digits[((b1 & 0x03) << 4) | (b2 >> 4)];
+ *b64++ = digits[(b2 & 0x0F) << 2];
+ *b64++ = '=';
+ }
+ *b64 = '\0';
+}
+
+unsigned long
+b64_orig_size(const char *text) {
+ const char *start = text;
+ unsigned long size = 0;
+
+ if ('\0' != *text) {
+ for (; 0 != *text; text++) { }
+ size = (text - start) * 3 / 4;
+ text--;
+ if ('=' == *text) {
+ size--;
+ text--;
+ if ('=' == *text) {
+ size--;
+ }
+ }
+ }
+ return size;
+}
+
+void
+from_base64(const char *b64, u_char *str) {
+ u_char b0, b1, b2, b3;
+
+ while (1) {
+ if ('X' == (b0 = s_digits[(u_char)*b64++])) { break; }
+ if ('X' == (b1 = s_digits[(u_char)*b64++])) { break; }
+ *str++ = (b0 << 2) | ((b1 >> 4) & 0x03);
+ if ('X' == (b2 = s_digits[(u_char)*b64++])) { break; }
+ *str++ = (b1 << 4) | ((b2 >> 2) & 0x0F);
+ if ('X' == (b3 = s_digits[(u_char)*b64++])) { break; }
+ *str++ = (b2 << 6) | b3;
+ }
+ *str = '\0';
+}
View
@@ -0,0 +1,44 @@
+/* base64.h
+ * Copyright (c) 2011, Peter Ohler
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * - 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.
+ *
+ * - Neither the name of Peter Ohler 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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 __BASE64_H__
+#define __BASE64_H__
+
+#include <sys/types.h>
+
+
+#define b64_size(len) ((len + 2) / 3 * 4)
+
+extern unsigned long b64_orig_size(const char *text);
+
+extern void to_base64(const u_char *src, int len, char *b64);
+extern void from_base64(const char *b64, u_char *str);
+
+#endif /* __BASE64_H__ */
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit b1a7937

Please sign in to comment.