swfmill 0.0.2 → 0.0.3

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.
data/.swfmill CHANGED
@@ -104,3 +104,24 @@ ext/swfmill/test/Makefile.in
104
104
  ext/swfmill/test/xml/Makefile.am
105
105
  ext/swfmill/test/xml/Makefile.in
106
106
  ext/swfmill/test/xml/test-xml
107
+ ext/libb64/Makefile
108
+ ext/libb64/BENCHMARKS
109
+ ext/libb64/base64/Makefile
110
+ ext/libb64/base64/base64.cc
111
+ ext/libb64/base64/VisualStudioProject/Makefile
112
+ ext/libb64/base64/VisualStudioProject/base64.vcxproj.filters
113
+ ext/libb64/base64/VisualStudioProject/base64.sln
114
+ ext/libb64/base64/VisualStudioProject/base64.vcxproj
115
+ ext/libb64/README
116
+ ext/libb64/INSTALL
117
+ ext/libb64/CHANGELOG
118
+ ext/libb64/include/b64/decode.h
119
+ ext/libb64/include/b64/cencode.h
120
+ ext/libb64/include/b64/encode.h
121
+ ext/libb64/include/b64/cdecode.h
122
+ ext/libb64/src/Makefile
123
+ ext/libb64/src/cdecode.c
124
+ ext/libb64/src/cencode.c
125
+ ext/libb64/LICENSE
126
+ ext/libb64/AUTHORS
127
+ ext/libb64/TODO
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -4,3 +4,4 @@ mkmf.log
4
4
  *.o
5
5
  *.so
6
6
  !test/Makefile
7
+ !libb64/**/Makefile
@@ -0,0 +1,21 @@
1
+ #include "b64/cdecode.h"
2
+ #include "b64/cencode.h"
3
+
4
+ long
5
+ base64_decode(char *to, char *from, unsigned int len)
6
+ {
7
+ base64_decodestate state;
8
+ base64_init_decodestate(&state);
9
+ return base64_decode_block(from, len, to, &state);
10
+ }
11
+
12
+ long
13
+ base64_encode(char *to, char *from, unsigned int len)
14
+ {
15
+ base64_encodestate state;
16
+ int size;
17
+ base64_init_encodestate(&state);
18
+ size = base64_encode_block(from, len, to, &state);
19
+ size+= base64_encode_blockend(to + size, &state);
20
+ return size;
21
+ }
@@ -98,7 +98,7 @@ have_func("iconv", "iconv.h") or have_library("iconv", "iconv", "iconv.h")
98
98
 
99
99
  have_library("stdc++")
100
100
 
101
- $CFLAGS += " -I./swfmill/src -I./swfmill/src/swft -I./swfmill/src/xslt"
101
+ $INCFLAGS += " -I./swfmill/src -I./swfmill/src/swft -I./swfmill/src/xslt -I./libb64/include"
102
102
 
103
103
  Dir.chdir("swfmill") do
104
104
  cmd = <<CMD
@@ -107,14 +107,28 @@ FREETYPE_CFLAGS="#{$FREETYPE_CFLAGS}" FREETYPE_LIBS="#{$FREETYPE_LIBS}" \
107
107
  XML_CFLAGS="#{$XML_CFLAGS}" XML_LIBS="#{$XML_LIBS}" \
108
108
  XSLT_CFLAGS="#{$XSLT_CFLAGS}" XSLT_LIBS="#{$XSLT_LIBS}" \
109
109
  PNG_CFLAGS="#{$PNG_CFLAGS}" PNG_LIBS="#{$PNG_LIBS}" \
110
- CXXFLAGS="-O3"
110
+ --with-pic \
111
+ --enable-shared \
112
+ CFLAGS="-fPIC -O3" \
113
+ CXXFLAGS="-fPIC -O3 -finline -finline-functions"
111
114
  CMD
112
115
  raise "error: #{cmd}" unless system(cmd)
113
116
  cmd = "make"
114
117
  raise "error: #{cmd}" unless system(cmd)
115
118
  end
116
119
 
120
+ Dir.chdir("libb64") do
121
+ cmd = "make"
122
+ raise "error: #{cmd}" unless system(cmd)
123
+ end
124
+
117
125
  create_makefile("swfmill_ext")
118
126
  File.open(File.dirname("__FILE__") + "/Makefile", "ab") do |f|
119
- f.puts "OBJS += #{Dir["swfmill/src/**/*.o"].join(" ")}"
127
+ exclude = ['swfmill/src/swfmill-base64.o']
128
+ objects = Dir["swfmill/src/**/*.o"] - exclude
129
+ f.puts "OBJS += #{objects.join(" ")}"
130
+ end
131
+
132
+ File.open(File.dirname("__FILE__") + "/Makefile", "ab") do |f|
133
+ f.puts "OBJS += libb64/src/cdecode.o libb64/src/cencode.o"
120
134
  end
@@ -0,0 +1,7 @@
1
+ libb64: Base64 Encoding/Decoding Routines
2
+ ======================================
3
+
4
+ Authors:
5
+ -------
6
+
7
+ Chris Venter chris.venter@gmail.com http://rocketpod.blogspot.com
@@ -0,0 +1,85 @@
1
+ -- Intro
2
+
3
+ Some people have expressed opinions about how
4
+ fast libb64's encoding and decoding routines
5
+ are, as compared to some other BASE64 packages
6
+ out there.
7
+
8
+ This document shows the result of a short and sweet
9
+ benchmark, which takes a large-ish file and
10
+ encodes/decodes it a number of times.
11
+ The winner is the executable that does this task the quickest.
12
+
13
+ -- Platform
14
+
15
+ The tests were all run on a Fujitsu-Siemens laptop,
16
+ with a Pentium M processor running at 2GHz, with
17
+ 1GB of RAM, running Ubuntu 10.4.
18
+
19
+ -- Packages
20
+
21
+ The following BASE64 packages were used in this benchmark:
22
+
23
+ - libb64-1.2 (libb64-base64)
24
+ From libb64.sourceforge.net
25
+ Size of executable: 18808 bytes
26
+ Compiled with:
27
+ CFLAGS += -O3
28
+ BUFFERSIZE = 16777216
29
+
30
+ - base64-1.5 (fourmilab-base64)
31
+ From http://www.fourmilab.ch/webtools/base64/
32
+ Size of executable: 20261 bytes
33
+ Compiled with Default package settings
34
+
35
+ - coreutils 7.4-2ubuntu2 (coreutils-base64)
36
+ From http://www.gnu.org/software/coreutils/
37
+ Size of executable: 38488 bytes
38
+ Default binary distributed with Ubuntu 10.4
39
+
40
+ -- Input File
41
+
42
+ Using blender-2.49b-linux-glibc236-py25-i386.tar.bz2
43
+ from http://www.blender.org/download/get-blender/
44
+ Size: 18285329 bytes
45
+ (approx. 18MB)
46
+
47
+ -- Method
48
+
49
+ Encode and Decode the Input file 50 times in a loop,
50
+ using a simple shell script, and get the running time.
51
+
52
+ -- Results
53
+
54
+ $ time ./benchmark-libb64.sh
55
+ real 0m28.389s
56
+ user 0m14.077s
57
+ sys 0m12.309s
58
+
59
+ $ time ./benchmark-fourmilab.sh
60
+ real 1m43.160s
61
+ user 1m23.769s
62
+ sys 0m8.737s
63
+
64
+ $ time ./benchmark-coreutils.sh
65
+ real 0m36.288s
66
+ user 0m24.746s
67
+ sys 0m8.181s
68
+
69
+ 28.389 for 18MB * 50
70
+ = 28.389 for 900
71
+
72
+ -- Conclusion
73
+
74
+ libb64 is the fastest encoder/decoder, and
75
+ has the smallest executable size.
76
+
77
+ On average it will encode and decode at roughly 31.7MB/second.
78
+
79
+ The closest "competitor" is base64 from GNU coreutils, which
80
+ reaches only 24.8MB/second.
81
+
82
+ --
83
+ 14/06/2010
84
+ chris.venter@gmail.com
85
+
@@ -0,0 +1,25 @@
1
+ libb64: Base64 Encoding/Decoding Routines
2
+ ======================================
3
+
4
+ ## Changelog ##
5
+
6
+ Version 1.2 Release
7
+ -------------------
8
+ Removed the b64dec, b64enc, encoder and decoder programs in favour of
9
+ a better example, called base64, which encodes and decodes
10
+ depending on its arguments.
11
+
12
+ Created a solution for Microsoft Visual Studio C++ Express 2010
13
+ edition, which simply builds the base64 example as a console application.
14
+
15
+ Version 1.1 Release
16
+ -------------------
17
+ Modified encode.h to (correctly) read from the iostream argument,
18
+ instead of std::cin.
19
+ Thanks to Peter K. Lee for the heads-up.
20
+
21
+ No API changes.
22
+
23
+ Version 1.0 Release
24
+ -------------------
25
+ The current content is the changeset.
@@ -0,0 +1,44 @@
1
+ libb64: Base64 Encoding/Decoding Routines
2
+ ======================================
3
+
4
+ Requirements:
5
+ ------------
6
+ This piece of software has minimal requirements.
7
+
8
+ I have tested it on the following systems:
9
+
10
+ - a Linux machine, with the following specs:
11
+ (this was the original development machine)
12
+ * FedoraCore 4
13
+ * kernel v. 2.6.11 (stock FC4 kernel)
14
+ * gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
15
+ * glibc-2.3.5-10
16
+ * make v. 3.80
17
+ * some arb version of makedepend
18
+
19
+ - Windows XP machine
20
+ * MSYS 1.0
21
+ * MinGW 5.1.4
22
+ * gcc version 3.4.5 (mingw-vista special r3)
23
+
24
+ - Windows XP machine (same as above)
25
+ * Microsoft Visual Studio 2010, Version 10.0.30319.1 RTMRel
26
+
27
+ Barring any serious screwups on my part, this code should compile and run sweetly
28
+ under Cygwin and other systems too. If you DO get it running under some weird arch/os setup,
29
+ send me a mail, please.
30
+
31
+ Compiling:
32
+ ---------
33
+ There is no configure. It would be overkill for something so simple...
34
+ Run make in the root directory.
35
+
36
+ Installing:
37
+ ----------
38
+ Since the current targets are a standalone executable and a static library
39
+ (fancy name for archive) with some headers, an install script has not been implemented yet.
40
+ Simply copy the executable into your path, and use it.
41
+
42
+ --
43
+ peace out
44
+ Chris
@@ -0,0 +1,29 @@
1
+ Copyright-Only Dedication (based on United States law)
2
+ or Public Domain Certification
3
+
4
+ The person or persons who have associated work with this document (the
5
+ "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of
6
+ his knowledge, the work of authorship identified is in the public domain of the
7
+ country from which the work is published, or (b) hereby dedicates whatever
8
+ copyright the dedicators holds in the work of authorship identified below (the
9
+ "Work") to the public domain. A certifier, moreover, dedicates any copyright
10
+ interest he may have in the associated work, and for these purposes, is
11
+ described as a "dedicator" below.
12
+
13
+ A certifier has taken reasonable steps to verify the copyright status of this
14
+ work. Certifier recognizes that his good faith efforts may not shield him from
15
+ liability if in fact the work certified is not in the public domain.
16
+
17
+ Dedicator makes this dedication for the benefit of the public at large and to
18
+ the detriment of the Dedicator's heirs and successors. Dedicator intends this
19
+ dedication to be an overt act of relinquishment in perpetuity of all present
20
+ and future rights under copyright law, whether vested or contingent, in the
21
+ Work. Dedicator understands that such relinquishment of all rights includes
22
+ the relinquishment of all rights to enforce (by lawsuit or otherwise) those
23
+ copyrights in the Work.
24
+
25
+ Dedicator recognizes that, once placed in the public domain, the Work may be
26
+ freely reproduced, distributed, transmitted, used, modified, built upon, or
27
+ otherwise exploited by anyone for any purpose, commercial or non-commercial,
28
+ and in any way, including by methods that have not yet been invented or
29
+ conceived.
@@ -0,0 +1,25 @@
1
+ all: all_src all_base64
2
+
3
+ all_src:
4
+ $(MAKE) -C src
5
+ all_base64: all_src
6
+ $(MAKE) -C base64
7
+
8
+ clean: clean_src clean_base64 clean_include
9
+ rm -f *~ *.bak
10
+
11
+ clean_include:
12
+ rm -f include/b64/*~
13
+
14
+ clean_src:
15
+ $(MAKE) -C src clean;
16
+ clean_base64:
17
+ $(MAKE) -C base64 clean;
18
+
19
+ distclean: clean distclean_src distclean_base64
20
+
21
+ distclean_src:
22
+ $(MAKE) -C src distclean;
23
+ distclean_base64:
24
+ $(MAKE) -C base64 distclean;
25
+
@@ -0,0 +1,138 @@
1
+ b64: Base64 Encoding/Decoding Routines
2
+ ======================================
3
+
4
+ Overview:
5
+ --------
6
+ libb64 is a library of ANSI C routines for fast encoding/decoding data into and
7
+ from a base64-encoded format. C++ wrappers are included, as well as the source
8
+ code for standalone encoding and decoding executables.
9
+
10
+ base64 consists of ASCII text, and is therefore a useful encoding for storing
11
+ binary data in a text file, such as xml, or sending binary data over text-only
12
+ email.
13
+
14
+ References:
15
+ ----------
16
+ * Wikipedia article:
17
+ http://en.wikipedia.org/wiki/Base64
18
+ * base64, another implementation of a commandline en/decoder:
19
+ http://www.fourmilab.ch/webtools/base64/
20
+
21
+ Why?
22
+ ---
23
+ I did this because I need an implementation of base64 encoding and decoding,
24
+ without any licensing problems. Most OS implementations are released under
25
+ either the GNU/GPL, or a BSD-variant, which is not what I require.
26
+
27
+ Also, the chance to actually use the co-routine implementation in code is rare,
28
+ and its use here is fitting. I couldn't pass up the chance.
29
+ For more information on this technique, see "Coroutines in C", by Simon Tatham,
30
+ which can be found online here:
31
+ http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
32
+
33
+ So then, under which license do I release this code? On to the next section...
34
+
35
+ License:
36
+ -------
37
+ This work is released under into the Public Domain.
38
+ It basically boils down to this: I put this work in the public domain, and you
39
+ can take it and do whatever you want with it.
40
+
41
+ An example of this "license" is the Creative Commons Public Domain License, a
42
+ copy of which can be found in the LICENSE file, and also online at
43
+ http://creativecommons.org/licenses/publicdomain/
44
+
45
+ Commandline Use:
46
+ ---------------
47
+ There is a new executable available, it is simply called base64.
48
+ It can encode and decode files, as instructed by the user.
49
+
50
+ To encode a file:
51
+ $ ./base64 -e filea fileb
52
+ fileb will now be the base64-encoded version of filea.
53
+
54
+ To decode a file:
55
+ $ ./base64 -d fileb filec
56
+ filec will now be identical to filea.
57
+
58
+ Programming:
59
+ -----------
60
+ Some C++ wrappers are provided as well, so you don't have to get your hands
61
+ dirty. Encoding from standard input to standard output is as simple as
62
+
63
+ #include <b64/encode.h>
64
+ #include <iostream>
65
+ int main()
66
+ {
67
+ base64::encoder E;
68
+ E.encode(std::cin, std::cout);
69
+ return 0;
70
+ }
71
+
72
+ Both standalone executables and a static library is provided in the package,
73
+
74
+ Implementation:
75
+ --------------
76
+ It is DAMN fast, if I may say so myself. The C code uses a little trick which
77
+ has been used to implement coroutines, of which one can say that this
78
+ implementation is an example.
79
+
80
+ (To see how the libb64 codebase compares with some other BASE64 implementations
81
+ available, see the BENCHMARKS file)
82
+
83
+ The trick involves the fact that a switch-statement may legally cross into
84
+ sub-blocks. A very thorough and enlightening essay on co-routines in C, using
85
+ this method, can be found in the above mentioned "Coroutines in C", by Simon
86
+ Tatham: http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
87
+
88
+ For example, an RLE decompressing routine, adapted from the article:
89
+ 1 static int STATE = 0;
90
+ 2 static int len, c;
91
+ 3 switch (STATE)
92
+ 4 {
93
+ 5 while (1)
94
+ 6 {
95
+ 7 c = getchar();
96
+ 8 if (c == EOF) return EOF;
97
+ 9 if (c == 0xFF) {
98
+ 10 len = getchar();
99
+ 11 c = getchar();
100
+ 12 while (len--)
101
+ 13 {
102
+ 14 STATE = 0;
103
+ 15 return c;
104
+ 16 case 0:
105
+ 17 }
106
+ 18 } else
107
+ 19 STATE = 1;
108
+ 20 return c;
109
+ 21 case 1:
110
+ 22 }
111
+ 23 }
112
+ 24 }
113
+
114
+ As can be seen from this example, a coroutine depends on a state variable,
115
+ which it sets directly before exiting (lines 14 and 119). The next time the
116
+ routine is entered, the switch moves control to the specific point directly
117
+ after the previous exit (lines 16 and 21).hands
118
+
119
+ (As an aside, in the mentioned article the combination of the top-level switch,
120
+ the various setting of the state, the return of a value, and the labelling of
121
+ the exit point is wrapped in #define macros, making the structure of the
122
+ routine even clearer.)
123
+
124
+ The obvious problem with any such routine is the static keyword.
125
+ Any static variables in a function spell doom for multithreaded applications.
126
+ Also, in situations where this coroutine is used by more than one other
127
+ coroutines, the consistency is disturbed.
128
+
129
+ What is needed is a structure for storing these variabled, which is passed to
130
+ the routine seperately. This obviously breaks the modularity of the function,
131
+ since now the caller has to worry about and care for the internal state of the
132
+ routine (the callee). This allows for a fast, multithreading-enabled
133
+ implementation, which may (obviously) be wrapped in a C++ object for ease of
134
+ use.
135
+
136
+ The base64 encoding and decoding functionality in this package is implemented
137
+ in exactly this way, providing both a high-speed high-maintanence C interface,
138
+ and a wrapped C++ which is low-maintanence and only slightly less performant.