swfmill 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.swfmill +21 -0
- data/VERSION +1 -1
- data/ext/.gitignore +1 -0
- data/ext/base64.c +21 -0
- data/ext/extconf.rb +17 -3
- data/ext/libb64/AUTHORS +7 -0
- data/ext/libb64/BENCHMARKS +85 -0
- data/ext/libb64/CHANGELOG +25 -0
- data/ext/libb64/INSTALL +44 -0
- data/ext/libb64/LICENSE +29 -0
- data/ext/libb64/Makefile +25 -0
- data/ext/libb64/README +138 -0
- data/ext/libb64/TODO +0 -0
- data/ext/libb64/base64/Makefile +56 -0
- data/ext/libb64/base64/VisualStudioProject/Makefile +11 -0
- data/ext/libb64/base64/VisualStudioProject/base64.sln +20 -0
- data/ext/libb64/base64/VisualStudioProject/base64.vcxproj +92 -0
- data/ext/libb64/base64/VisualStudioProject/base64.vcxproj.filters +36 -0
- data/ext/libb64/base64/base64.cc +94 -0
- data/ext/libb64/include/b64/cdecode.h +28 -0
- data/ext/libb64/include/b64/cencode.h +31 -0
- data/ext/libb64/include/b64/decode.h +70 -0
- data/ext/libb64/include/b64/encode.h +77 -0
- data/ext/libb64/src/Makefile +43 -0
- data/ext/libb64/src/cdecode.c +88 -0
- data/ext/libb64/src/cencode.c +109 -0
- data/ext/swfmill/src/SWFItem.cpp +2 -0
- data/ext/swfmill/src/SWFItem.h +7 -2
- data/ext/swfmill/src/swfmill.cpp +2 -2
- data/ext/swfmill_ext.cc +12 -0
- data/ext/swfmill_ext_to_swf.cc +2 -0
- data/ext/swfmill_ext_to_xml.cc +2 -10
- metadata +26 -4
@@ -0,0 +1,77 @@
|
|
1
|
+
// :mode=c++:
|
2
|
+
/*
|
3
|
+
encode.h - c++ wrapper for a base64 encoding algorithm
|
4
|
+
|
5
|
+
This is part of the libb64 project, and has been placed in the public domain.
|
6
|
+
For details, see http://sourceforge.net/projects/libb64
|
7
|
+
*/
|
8
|
+
#ifndef BASE64_ENCODE_H
|
9
|
+
#define BASE64_ENCODE_H
|
10
|
+
|
11
|
+
#include <iostream>
|
12
|
+
|
13
|
+
namespace base64
|
14
|
+
{
|
15
|
+
extern "C"
|
16
|
+
{
|
17
|
+
#include "cencode.h"
|
18
|
+
}
|
19
|
+
|
20
|
+
struct encoder
|
21
|
+
{
|
22
|
+
base64_encodestate _state;
|
23
|
+
int _buffersize;
|
24
|
+
|
25
|
+
encoder(int buffersize_in = BUFFERSIZE)
|
26
|
+
: _buffersize(buffersize_in)
|
27
|
+
{}
|
28
|
+
|
29
|
+
int encode(char value_in)
|
30
|
+
{
|
31
|
+
return base64_encode_value(value_in);
|
32
|
+
}
|
33
|
+
|
34
|
+
int encode(const char* code_in, const int length_in, char* plaintext_out)
|
35
|
+
{
|
36
|
+
return base64_encode_block(code_in, length_in, plaintext_out, &_state);
|
37
|
+
}
|
38
|
+
|
39
|
+
int encode_end(char* plaintext_out)
|
40
|
+
{
|
41
|
+
return base64_encode_blockend(plaintext_out, &_state);
|
42
|
+
}
|
43
|
+
|
44
|
+
void encode(std::istream& istream_in, std::ostream& ostream_in)
|
45
|
+
{
|
46
|
+
base64_init_encodestate(&_state);
|
47
|
+
//
|
48
|
+
const int N = _buffersize;
|
49
|
+
char* plaintext = new char[N];
|
50
|
+
char* code = new char[2*N];
|
51
|
+
int plainlength;
|
52
|
+
int codelength;
|
53
|
+
|
54
|
+
do
|
55
|
+
{
|
56
|
+
istream_in.read(plaintext, N);
|
57
|
+
plainlength = istream_in.gcount();
|
58
|
+
//
|
59
|
+
codelength = encode(plaintext, plainlength, code);
|
60
|
+
ostream_in.write(code, codelength);
|
61
|
+
}
|
62
|
+
while (istream_in.good() && plainlength > 0);
|
63
|
+
|
64
|
+
codelength = encode_end(code);
|
65
|
+
ostream_in.write(code, codelength);
|
66
|
+
//
|
67
|
+
base64_init_encodestate(&_state);
|
68
|
+
|
69
|
+
delete [] code;
|
70
|
+
delete [] plaintext;
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
} // namespace base64
|
75
|
+
|
76
|
+
#endif // BASE64_ENCODE_H
|
77
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
LIBRARIES = libb64.a
|
2
|
+
|
3
|
+
# Build flags (uncomment one)
|
4
|
+
#############################
|
5
|
+
# Release build flags
|
6
|
+
CFLAGS += -fPIC -O3
|
7
|
+
#############################
|
8
|
+
# Debug build flags
|
9
|
+
#CFLAGS += -g
|
10
|
+
#############################
|
11
|
+
|
12
|
+
SOURCES = cdecode.c cencode.c
|
13
|
+
|
14
|
+
TARGETS = $(LIBRARIES)
|
15
|
+
|
16
|
+
LINK.o = gcc
|
17
|
+
|
18
|
+
CFLAGS += -Werror -pedantic
|
19
|
+
CFLAGS += -I../include
|
20
|
+
|
21
|
+
vpath %.h ../include/b64
|
22
|
+
|
23
|
+
.PHONY : clean
|
24
|
+
|
25
|
+
all: $(TARGETS) #strip
|
26
|
+
|
27
|
+
libb64.a: cencode.o cdecode.o
|
28
|
+
$(AR) $(ARFLAGS) $@ $^
|
29
|
+
|
30
|
+
strip:
|
31
|
+
strip $(BINARIES) *.exe
|
32
|
+
|
33
|
+
clean:
|
34
|
+
rm -f *.exe* *.o $(TARGETS) *.bak *~
|
35
|
+
|
36
|
+
distclean: clean
|
37
|
+
rm -f depend
|
38
|
+
|
39
|
+
depend: $(SOURCES)
|
40
|
+
makedepend -f- $(CFLAGS) $(SOURCES) 2> /dev/null 1> depend
|
41
|
+
|
42
|
+
-include depend
|
43
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
/*
|
2
|
+
cdecoder.c - c source to a base64 decoding algorithm implementation
|
3
|
+
|
4
|
+
This is part of the libb64 project, and has been placed in the public domain.
|
5
|
+
For details, see http://sourceforge.net/projects/libb64
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include <b64/cdecode.h>
|
9
|
+
|
10
|
+
int base64_decode_value(char value_in)
|
11
|
+
{
|
12
|
+
static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
|
13
|
+
static const char decoding_size = sizeof(decoding);
|
14
|
+
value_in -= 43;
|
15
|
+
if (value_in < 0 || value_in > decoding_size) return -1;
|
16
|
+
return decoding[(int)value_in];
|
17
|
+
}
|
18
|
+
|
19
|
+
void base64_init_decodestate(base64_decodestate* state_in)
|
20
|
+
{
|
21
|
+
state_in->step = step_a;
|
22
|
+
state_in->plainchar = 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in)
|
26
|
+
{
|
27
|
+
const char* codechar = code_in;
|
28
|
+
char* plainchar = plaintext_out;
|
29
|
+
char fragment;
|
30
|
+
|
31
|
+
*plainchar = state_in->plainchar;
|
32
|
+
|
33
|
+
switch (state_in->step)
|
34
|
+
{
|
35
|
+
while (1)
|
36
|
+
{
|
37
|
+
case step_a:
|
38
|
+
do {
|
39
|
+
if (codechar == code_in+length_in)
|
40
|
+
{
|
41
|
+
state_in->step = step_a;
|
42
|
+
state_in->plainchar = *plainchar;
|
43
|
+
return plainchar - plaintext_out;
|
44
|
+
}
|
45
|
+
fragment = (char)base64_decode_value(*codechar++);
|
46
|
+
} while (fragment < 0);
|
47
|
+
*plainchar = (fragment & 0x03f) << 2;
|
48
|
+
case step_b:
|
49
|
+
do {
|
50
|
+
if (codechar == code_in+length_in)
|
51
|
+
{
|
52
|
+
state_in->step = step_b;
|
53
|
+
state_in->plainchar = *plainchar;
|
54
|
+
return plainchar - plaintext_out;
|
55
|
+
}
|
56
|
+
fragment = (char)base64_decode_value(*codechar++);
|
57
|
+
} while (fragment < 0);
|
58
|
+
*plainchar++ |= (fragment & 0x030) >> 4;
|
59
|
+
*plainchar = (fragment & 0x00f) << 4;
|
60
|
+
case step_c:
|
61
|
+
do {
|
62
|
+
if (codechar == code_in+length_in)
|
63
|
+
{
|
64
|
+
state_in->step = step_c;
|
65
|
+
state_in->plainchar = *plainchar;
|
66
|
+
return plainchar - plaintext_out;
|
67
|
+
}
|
68
|
+
fragment = (char)base64_decode_value(*codechar++);
|
69
|
+
} while (fragment < 0);
|
70
|
+
*plainchar++ |= (fragment & 0x03c) >> 2;
|
71
|
+
*plainchar = (fragment & 0x003) << 6;
|
72
|
+
case step_d:
|
73
|
+
do {
|
74
|
+
if (codechar == code_in+length_in)
|
75
|
+
{
|
76
|
+
state_in->step = step_d;
|
77
|
+
state_in->plainchar = *plainchar;
|
78
|
+
return plainchar - plaintext_out;
|
79
|
+
}
|
80
|
+
fragment = (char)base64_decode_value(*codechar++);
|
81
|
+
} while (fragment < 0);
|
82
|
+
*plainchar++ |= (fragment & 0x03f);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
/* control should not reach here */
|
86
|
+
return plainchar - plaintext_out;
|
87
|
+
}
|
88
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/*
|
2
|
+
cencoder.c - c source to a base64 encoding algorithm implementation
|
3
|
+
|
4
|
+
This is part of the libb64 project, and has been placed in the public domain.
|
5
|
+
For details, see http://sourceforge.net/projects/libb64
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include <b64/cencode.h>
|
9
|
+
|
10
|
+
const int CHARS_PER_LINE = 72;
|
11
|
+
|
12
|
+
void base64_init_encodestate(base64_encodestate* state_in)
|
13
|
+
{
|
14
|
+
state_in->step = step_A;
|
15
|
+
state_in->result = 0;
|
16
|
+
state_in->stepcount = 0;
|
17
|
+
}
|
18
|
+
|
19
|
+
char base64_encode_value(char value_in)
|
20
|
+
{
|
21
|
+
static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
22
|
+
if (value_in > 63) return '=';
|
23
|
+
return encoding[(int)value_in];
|
24
|
+
}
|
25
|
+
|
26
|
+
int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in)
|
27
|
+
{
|
28
|
+
const char* plainchar = plaintext_in;
|
29
|
+
const char* const plaintextend = plaintext_in + length_in;
|
30
|
+
char* codechar = code_out;
|
31
|
+
char result;
|
32
|
+
char fragment;
|
33
|
+
|
34
|
+
result = state_in->result;
|
35
|
+
|
36
|
+
switch (state_in->step)
|
37
|
+
{
|
38
|
+
while (1)
|
39
|
+
{
|
40
|
+
case step_A:
|
41
|
+
if (plainchar == plaintextend)
|
42
|
+
{
|
43
|
+
state_in->result = result;
|
44
|
+
state_in->step = step_A;
|
45
|
+
return codechar - code_out;
|
46
|
+
}
|
47
|
+
fragment = *plainchar++;
|
48
|
+
result = (fragment & 0x0fc) >> 2;
|
49
|
+
*codechar++ = base64_encode_value(result);
|
50
|
+
result = (fragment & 0x003) << 4;
|
51
|
+
case step_B:
|
52
|
+
if (plainchar == plaintextend)
|
53
|
+
{
|
54
|
+
state_in->result = result;
|
55
|
+
state_in->step = step_B;
|
56
|
+
return codechar - code_out;
|
57
|
+
}
|
58
|
+
fragment = *plainchar++;
|
59
|
+
result |= (fragment & 0x0f0) >> 4;
|
60
|
+
*codechar++ = base64_encode_value(result);
|
61
|
+
result = (fragment & 0x00f) << 2;
|
62
|
+
case step_C:
|
63
|
+
if (plainchar == plaintextend)
|
64
|
+
{
|
65
|
+
state_in->result = result;
|
66
|
+
state_in->step = step_C;
|
67
|
+
return codechar - code_out;
|
68
|
+
}
|
69
|
+
fragment = *plainchar++;
|
70
|
+
result |= (fragment & 0x0c0) >> 6;
|
71
|
+
*codechar++ = base64_encode_value(result);
|
72
|
+
result = (fragment & 0x03f) >> 0;
|
73
|
+
*codechar++ = base64_encode_value(result);
|
74
|
+
|
75
|
+
++(state_in->stepcount);
|
76
|
+
if (state_in->stepcount == CHARS_PER_LINE/4)
|
77
|
+
{
|
78
|
+
*codechar++ = '\n';
|
79
|
+
state_in->stepcount = 0;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
/* control should not reach here */
|
84
|
+
return codechar - code_out;
|
85
|
+
}
|
86
|
+
|
87
|
+
int base64_encode_blockend(char* code_out, base64_encodestate* state_in)
|
88
|
+
{
|
89
|
+
char* codechar = code_out;
|
90
|
+
|
91
|
+
switch (state_in->step)
|
92
|
+
{
|
93
|
+
case step_B:
|
94
|
+
*codechar++ = base64_encode_value(state_in->result);
|
95
|
+
*codechar++ = '=';
|
96
|
+
*codechar++ = '=';
|
97
|
+
break;
|
98
|
+
case step_C:
|
99
|
+
*codechar++ = base64_encode_value(state_in->result);
|
100
|
+
*codechar++ = '=';
|
101
|
+
break;
|
102
|
+
case step_A:
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
*codechar++ = '\n';
|
106
|
+
|
107
|
+
return codechar - code_out;
|
108
|
+
}
|
109
|
+
|
data/ext/swfmill/src/SWFItem.cpp
CHANGED
@@ -103,12 +103,14 @@ Item::Item() {
|
|
103
103
|
cached_size = -1;
|
104
104
|
}
|
105
105
|
|
106
|
+
#if 0
|
106
107
|
size_t Item::getSize( Context *ctx, int start_at ) {
|
107
108
|
if( cached_size == -1 ) {
|
108
109
|
cached_size = calcSize( ctx, start_at );
|
109
110
|
}
|
110
111
|
return cached_size;
|
111
112
|
}
|
113
|
+
#endif
|
112
114
|
|
113
115
|
int Item::getHeaderSize( int size ) {
|
114
116
|
return 0;
|
data/ext/swfmill/src/SWFItem.h
CHANGED
@@ -26,8 +26,13 @@ class Item {
|
|
26
26
|
virtual void parseXML( xmlNodePtr xml, Context *ctx ) = 0;
|
27
27
|
|
28
28
|
// wont touch the context if size is cached.
|
29
|
-
size_t getSize( Context *ctx, int start_at )
|
30
|
-
|
29
|
+
size_t getSize( Context *ctx, int start_at ) {
|
30
|
+
if( cached_size == -1 ) {
|
31
|
+
cached_size = calcSize( ctx, start_at );
|
32
|
+
}
|
33
|
+
return cached_size;
|
34
|
+
}
|
35
|
+
|
31
36
|
protected:
|
32
37
|
int getHeaderSize( int size );
|
33
38
|
void writeHeader( Writer *w, Context *ctx, size_t len );
|
data/ext/swfmill/src/swfmill.cpp
CHANGED
@@ -341,8 +341,8 @@ fail:
|
|
341
341
|
void swfmill_create_library( xmlNodePtr lib, const char *filename );
|
342
342
|
|
343
343
|
void swfmill_create_library_dir( xmlNodePtr lib, const char *dir ) {
|
344
|
-
char tmp[
|
345
|
-
|
344
|
+
char tmp[1024];
|
345
|
+
|
346
346
|
struct dirent *e;
|
347
347
|
DIR *d = opendir( dir );
|
348
348
|
if( d == NULL ) return;
|
data/ext/swfmill_ext.cc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "ruby.h"
|
2
2
|
#include "swfmill_ext_to_xml.h"
|
3
3
|
#include "swfmill_ext_to_swf.h"
|
4
|
+
#include <libxml/xmlmemory.h>
|
4
5
|
|
5
6
|
VALUE rb_mSwfmill;
|
6
7
|
VALUE rb_eSwfmill_Error;
|
@@ -8,8 +9,19 @@ VALUE rb_eSwfmill_EOFError;
|
|
8
9
|
|
9
10
|
extern "C" {
|
10
11
|
|
12
|
+
static void
|
13
|
+
init_xml_memory()
|
14
|
+
{
|
15
|
+
xmlMemSetup((xmlFreeFunc)ruby_xfree,
|
16
|
+
(xmlMallocFunc)ruby_xmalloc,
|
17
|
+
(xmlReallocFunc)ruby_xrealloc,
|
18
|
+
strdup);
|
19
|
+
}
|
20
|
+
|
11
21
|
void Init_swfmill_ext(void)
|
12
22
|
{
|
23
|
+
init_xml_memory();
|
24
|
+
|
13
25
|
rb_mSwfmill = rb_define_module("Swfmill");
|
14
26
|
rb_eSwfmill_Error = rb_define_class_under(rb_mSwfmill, "Error", rb_eStandardError);
|
15
27
|
rb_eSwfmill_EOFError = rb_define_class_under(rb_mSwfmill, "EOFError", rb_eStandardError);
|
data/ext/swfmill_ext_to_swf.cc
CHANGED
data/ext/swfmill_ext_to_xml.cc
CHANGED
@@ -35,6 +35,8 @@ stx_free(swfmill_to_xml * const stx)
|
|
35
35
|
stx->header = NULL;
|
36
36
|
delete stx->context;
|
37
37
|
stx->context = NULL;
|
38
|
+
|
39
|
+
xfree(stx);
|
38
40
|
}
|
39
41
|
}
|
40
42
|
|
@@ -162,15 +164,6 @@ stx_parse(swfmill_to_xml* const stx)
|
|
162
164
|
return true;
|
163
165
|
}
|
164
166
|
|
165
|
-
static void
|
166
|
-
stx_init_xml_memory()
|
167
|
-
{
|
168
|
-
xmlMemSetup((xmlFreeFunc)ruby_xfree,
|
169
|
-
(xmlMallocFunc)ruby_xmalloc,
|
170
|
-
(xmlReallocFunc)ruby_xrealloc,
|
171
|
-
strdup);
|
172
|
-
}
|
173
|
-
|
174
167
|
static void
|
175
168
|
stx_set_version_proparty(const swfmill_to_xml* const stx, xmlNodePtr root)
|
176
169
|
{
|
@@ -220,7 +213,6 @@ stx_to_string(swfmill_to_xml* const stx)
|
|
220
213
|
VALUE xml = Qnil;
|
221
214
|
xmlDocPtr doc;
|
222
215
|
xmlNodePtr root;
|
223
|
-
stx_init_xml_memory();
|
224
216
|
|
225
217
|
doc = xmlNewDoc((const xmlChar*)"1.0");
|
226
218
|
root = doc->xmlRootNode = xmlNewDocNode(doc, NULL, (const xmlChar*)"swf", NULL);
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swfmill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- miyucy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-17 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -52,10 +52,32 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- VERSION
|
54
54
|
- ext/.gitignore
|
55
|
+
- ext/base64.c
|
55
56
|
- ext/buffer.h
|
56
57
|
- ext/deflate.h
|
57
58
|
- ext/extconf.rb
|
58
59
|
- ext/inflate.h
|
60
|
+
- ext/libb64/AUTHORS
|
61
|
+
- ext/libb64/BENCHMARKS
|
62
|
+
- ext/libb64/CHANGELOG
|
63
|
+
- ext/libb64/INSTALL
|
64
|
+
- ext/libb64/LICENSE
|
65
|
+
- ext/libb64/Makefile
|
66
|
+
- ext/libb64/README
|
67
|
+
- ext/libb64/TODO
|
68
|
+
- ext/libb64/base64/Makefile
|
69
|
+
- ext/libb64/base64/VisualStudioProject/Makefile
|
70
|
+
- ext/libb64/base64/VisualStudioProject/base64.sln
|
71
|
+
- ext/libb64/base64/VisualStudioProject/base64.vcxproj
|
72
|
+
- ext/libb64/base64/VisualStudioProject/base64.vcxproj.filters
|
73
|
+
- ext/libb64/base64/base64.cc
|
74
|
+
- ext/libb64/include/b64/cdecode.h
|
75
|
+
- ext/libb64/include/b64/cencode.h
|
76
|
+
- ext/libb64/include/b64/decode.h
|
77
|
+
- ext/libb64/include/b64/encode.h
|
78
|
+
- ext/libb64/src/Makefile
|
79
|
+
- ext/libb64/src/cdecode.c
|
80
|
+
- ext/libb64/src/cencode.c
|
59
81
|
- ext/swfmill/.gitignore
|
60
82
|
- ext/swfmill/AUTHORS
|
61
83
|
- ext/swfmill/COPYING
|