ruby-tls 1.0.2 → 1.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.
- checksums.yaml +4 -4
- data/EM-LICENSE +60 -60
- data/README.md +71 -71
- data/Rakefile +19 -19
- data/ext/Rakefile +18 -18
- data/ext/tls/page.cpp +102 -102
- data/ext/tls/page.h +61 -61
- data/ext/tls/ssl.cpp +594 -587
- data/ext/tls/ssl.h +130 -129
- data/lib/ruby-tls.rb +7 -7
- data/lib/ruby-tls/connection.rb +124 -121
- data/lib/ruby-tls/ext.rb +39 -38
- data/lib/ruby-tls/version.rb +3 -3
- data/ruby-tls.gemspec +32 -32
- data/spec/client.crt +31 -31
- data/spec/client.key +51 -51
- data/spec/comms_spec.rb +156 -147
- data/spec/verify_spec.rb +120 -118
- metadata +34 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fc0dda5fe9d4c27285d3edd638c41042e03c38b
|
4
|
+
data.tar.gz: dd6678ff4e8361f5f1cb348408493bc4df58b3ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731a5c8d44bf7581111e49b1ad398eb976ee0b02cacd416d0ffc2b7a47f44d92f8470be37d3ffd2437b2ec1a9d47f839143de62eea3268064dba395b711bc018
|
7
|
+
data.tar.gz: 46a86dc3bb5ff2bd117d856cd8cc33355dd735a335127d34e723bc6a49f7bb83458faad0c807f9b2de0f80979d0a793dcc9eef5a819f4a4ed7c2fa1730b2486a
|
data/EM-LICENSE
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
EventMachine is copyrighted free software owned by Francis Cianfrocca
|
2
|
-
(blackhedd ... gmail.com). The Owner of this software permits you to
|
3
|
-
redistribute and/or modify the software under either the terms of the GPL
|
4
|
-
version 2 (see the file GPL), or the conditions below ("Ruby License"):
|
5
|
-
|
6
|
-
1. You may make and give away verbatim copies of the source form of this
|
7
|
-
software without restriction, provided that you retain ALL of the
|
8
|
-
original copyright notices and associated disclaimers.
|
9
|
-
|
10
|
-
2. You may modify your copy of the software in any way, provided that
|
11
|
-
you do at least ONE of the following:
|
12
|
-
|
13
|
-
a) place your modifications in the Public Domain or otherwise
|
14
|
-
make them Freely Available, such as by posting said
|
15
|
-
modifications to Usenet or an equivalent medium, or by allowing
|
16
|
-
the author to include your modifications in the software.
|
17
|
-
|
18
|
-
b) use the modified software only within your corporation or
|
19
|
-
organization.
|
20
|
-
|
21
|
-
c) give non-standard binaries non-standard names, with
|
22
|
-
instructions on where to get the original software distribution.
|
23
|
-
|
24
|
-
d) make other distribution arrangements with the Owner.
|
25
|
-
|
26
|
-
3. You may distribute the software in object code or binary form,
|
27
|
-
provided that you do at least ONE of the following:
|
28
|
-
|
29
|
-
a) distribute the binaries and library files of the software,
|
30
|
-
together with instructions (in a manual page or equivalent)
|
31
|
-
on where to get the original distribution.
|
32
|
-
|
33
|
-
b) accompany the distribution with the machine-readable source of
|
34
|
-
the software.
|
35
|
-
|
36
|
-
c) give non-standard binaries non-standard names, with
|
37
|
-
instructions on where to get the original software distribution.
|
38
|
-
|
39
|
-
d) make other distribution arrangements with the Owner.
|
40
|
-
|
41
|
-
4. You may modify and include parts of the software into any other
|
42
|
-
software (possibly commercial), provided you comply with the terms in
|
43
|
-
Sections 1, 2, and 3 above. But some files in the distribution
|
44
|
-
are not written by the Owner, so they may be made available to you
|
45
|
-
under different terms.
|
46
|
-
|
47
|
-
For the list of those files and their copying conditions, see the
|
48
|
-
file LEGAL.
|
49
|
-
|
50
|
-
5. The scripts and library files supplied as input to or produced as
|
51
|
-
output from the software do not automatically fall under the
|
52
|
-
copyright of the software, but belong to whoever generated them,
|
53
|
-
and may be sold commercially, and may be aggregated with this
|
54
|
-
software.
|
55
|
-
|
56
|
-
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
57
|
-
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
58
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
59
|
-
PURPOSE.
|
60
|
-
|
1
|
+
EventMachine is copyrighted free software owned by Francis Cianfrocca
|
2
|
+
(blackhedd ... gmail.com). The Owner of this software permits you to
|
3
|
+
redistribute and/or modify the software under either the terms of the GPL
|
4
|
+
version 2 (see the file GPL), or the conditions below ("Ruby License"):
|
5
|
+
|
6
|
+
1. You may make and give away verbatim copies of the source form of this
|
7
|
+
software without restriction, provided that you retain ALL of the
|
8
|
+
original copyright notices and associated disclaimers.
|
9
|
+
|
10
|
+
2. You may modify your copy of the software in any way, provided that
|
11
|
+
you do at least ONE of the following:
|
12
|
+
|
13
|
+
a) place your modifications in the Public Domain or otherwise
|
14
|
+
make them Freely Available, such as by posting said
|
15
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
16
|
+
the author to include your modifications in the software.
|
17
|
+
|
18
|
+
b) use the modified software only within your corporation or
|
19
|
+
organization.
|
20
|
+
|
21
|
+
c) give non-standard binaries non-standard names, with
|
22
|
+
instructions on where to get the original software distribution.
|
23
|
+
|
24
|
+
d) make other distribution arrangements with the Owner.
|
25
|
+
|
26
|
+
3. You may distribute the software in object code or binary form,
|
27
|
+
provided that you do at least ONE of the following:
|
28
|
+
|
29
|
+
a) distribute the binaries and library files of the software,
|
30
|
+
together with instructions (in a manual page or equivalent)
|
31
|
+
on where to get the original distribution.
|
32
|
+
|
33
|
+
b) accompany the distribution with the machine-readable source of
|
34
|
+
the software.
|
35
|
+
|
36
|
+
c) give non-standard binaries non-standard names, with
|
37
|
+
instructions on where to get the original software distribution.
|
38
|
+
|
39
|
+
d) make other distribution arrangements with the Owner.
|
40
|
+
|
41
|
+
4. You may modify and include parts of the software into any other
|
42
|
+
software (possibly commercial), provided you comply with the terms in
|
43
|
+
Sections 1, 2, and 3 above. But some files in the distribution
|
44
|
+
are not written by the Owner, so they may be made available to you
|
45
|
+
under different terms.
|
46
|
+
|
47
|
+
For the list of those files and their copying conditions, see the
|
48
|
+
file LEGAL.
|
49
|
+
|
50
|
+
5. The scripts and library files supplied as input to or produced as
|
51
|
+
output from the software do not automatically fall under the
|
52
|
+
copyright of the software, but belong to whoever generated them,
|
53
|
+
and may be sold commercially, and may be aggregated with this
|
54
|
+
software.
|
55
|
+
|
56
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
57
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
58
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
59
|
+
PURPOSE.
|
60
|
+
|
data/README.md
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
# ruby-tls
|
2
|
-
|
3
|
-
Ruby-TLS decouples the management of encrypted communications, putting you in charge of the transport layer. It can be used as an alternative to Ruby's SSLSocket.
|
4
|
-
|
5
|
-
[](https://travis-ci.org/cotag/ruby-tls)
|
6
|
-
|
7
|
-
|
8
|
-
## Install the gem
|
9
|
-
|
10
|
-
Install it with [RubyGems](https://rubygems.org/)
|
11
|
-
|
12
|
-
gem install ruby-tls
|
13
|
-
|
14
|
-
or add this to your Gemfile if you use [Bundler](http://gembundler.com/):
|
15
|
-
|
16
|
-
gem "ruby-tls"
|
17
|
-
|
18
|
-
|
19
|
-
Windows users will require an installation of OpenSSL (32bit or 64bit matching the Ruby installation) and be setup with [Ruby Installers DevKit](http://rubyinstaller.org/downloads/)
|
20
|
-
|
21
|
-
|
22
|
-
## Usage
|
23
|
-
|
24
|
-
```ruby
|
25
|
-
require 'rubygems'
|
26
|
-
require 'ruby-tls'
|
27
|
-
|
28
|
-
#
|
29
|
-
# Create a new TLS connection and attach callbacks
|
30
|
-
#
|
31
|
-
connection = RubyTls::Connection.new do |state|
|
32
|
-
state.handshake_cb do
|
33
|
-
puts "TLS handshake complete"
|
34
|
-
end
|
35
|
-
|
36
|
-
state.transmit_cb do |data|
|
37
|
-
puts "Data for transmission to remote"
|
38
|
-
end
|
39
|
-
|
40
|
-
state.dispatch_cb do |data|
|
41
|
-
puts "Clear text data that has been decrypted"
|
42
|
-
end
|
43
|
-
|
44
|
-
state.close_cb do |inst, data|
|
45
|
-
puts "An error occurred, the transport layer should be shutdown"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# Init the handshake
|
51
|
-
#
|
52
|
-
connection.start
|
53
|
-
|
54
|
-
#
|
55
|
-
# Start sending data to the remote, this will trigger the
|
56
|
-
# transmit_cb with encrypted data to send.
|
57
|
-
#
|
58
|
-
connection.encrypt('client request')
|
59
|
-
|
60
|
-
#
|
61
|
-
# Similarly when data is received from the remote it should be
|
62
|
-
# passed to connection.decrypt where the dispatch_cb will be
|
63
|
-
# called with clear text
|
64
|
-
#
|
65
|
-
```
|
66
|
-
|
67
|
-
|
68
|
-
## License and copyright
|
69
|
-
|
70
|
-
The core SSL code was originally extracted and isolated from [EventMachine](https://github.com/eventmachine/eventmachine/). So is licensed under the same terms, either the GPL or Ruby's License.
|
71
|
-
|
1
|
+
# ruby-tls
|
2
|
+
|
3
|
+
Ruby-TLS decouples the management of encrypted communications, putting you in charge of the transport layer. It can be used as an alternative to Ruby's SSLSocket.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/cotag/ruby-tls)
|
6
|
+
|
7
|
+
|
8
|
+
## Install the gem
|
9
|
+
|
10
|
+
Install it with [RubyGems](https://rubygems.org/)
|
11
|
+
|
12
|
+
gem install ruby-tls
|
13
|
+
|
14
|
+
or add this to your Gemfile if you use [Bundler](http://gembundler.com/):
|
15
|
+
|
16
|
+
gem "ruby-tls"
|
17
|
+
|
18
|
+
|
19
|
+
Windows users will require an installation of OpenSSL (32bit or 64bit matching the Ruby installation) and be setup with [Ruby Installers DevKit](http://rubyinstaller.org/downloads/)
|
20
|
+
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'rubygems'
|
26
|
+
require 'ruby-tls'
|
27
|
+
|
28
|
+
#
|
29
|
+
# Create a new TLS connection and attach callbacks
|
30
|
+
#
|
31
|
+
connection = RubyTls::Connection.new do |state|
|
32
|
+
state.handshake_cb do
|
33
|
+
puts "TLS handshake complete"
|
34
|
+
end
|
35
|
+
|
36
|
+
state.transmit_cb do |data|
|
37
|
+
puts "Data for transmission to remote"
|
38
|
+
end
|
39
|
+
|
40
|
+
state.dispatch_cb do |data|
|
41
|
+
puts "Clear text data that has been decrypted"
|
42
|
+
end
|
43
|
+
|
44
|
+
state.close_cb do |inst, data|
|
45
|
+
puts "An error occurred, the transport layer should be shutdown"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
# Init the handshake
|
51
|
+
#
|
52
|
+
connection.start
|
53
|
+
|
54
|
+
#
|
55
|
+
# Start sending data to the remote, this will trigger the
|
56
|
+
# transmit_cb with encrypted data to send.
|
57
|
+
#
|
58
|
+
connection.encrypt('client request')
|
59
|
+
|
60
|
+
#
|
61
|
+
# Similarly when data is received from the remote it should be
|
62
|
+
# passed to connection.decrypt where the dispatch_cb will be
|
63
|
+
# called with clear text
|
64
|
+
#
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
## License and copyright
|
69
|
+
|
70
|
+
The core SSL code was originally extracted and isolated from [EventMachine](https://github.com/eventmachine/eventmachine/). So is licensed under the same terms, either the GPL or Ruby's License.
|
71
|
+
|
data/Rakefile
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
|
5
|
-
task :default => [:compile, :test]
|
6
|
-
|
7
|
-
task :compile do
|
8
|
-
protect = ['ssl.cpp', 'ssl.h', 'page.cpp', 'page.h']
|
9
|
-
Dir["ext/tls/**/*"].each do |file|
|
10
|
-
begin
|
11
|
-
next if protect.include? File.basename(file)
|
12
|
-
FileUtils.rm file
|
13
|
-
rescue
|
14
|
-
end
|
15
|
-
end
|
16
|
-
system 'cd ext && rake'
|
17
|
-
end
|
18
|
-
|
19
|
-
RSpec::Core::RakeTask.new(:test)
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
task :default => [:compile, :test]
|
6
|
+
|
7
|
+
task :compile do
|
8
|
+
protect = ['ssl.cpp', 'ssl.h', 'page.cpp', 'page.h']
|
9
|
+
Dir["ext/tls/**/*"].each do |file|
|
10
|
+
begin
|
11
|
+
next if protect.include? File.basename(file)
|
12
|
+
FileUtils.rm file
|
13
|
+
rescue
|
14
|
+
end
|
15
|
+
end
|
16
|
+
system 'cd ext && rake'
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new(:test)
|
data/ext/Rakefile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require 'ffi-compiler/compile_task'
|
2
|
-
|
3
|
-
FFI::Compiler::CompileTask.new('ruby-tls-ext') do |t|
|
4
|
-
t.cflags << "-Wall -Wextra -O3"
|
5
|
-
t.cflags << "-D_GNU_SOURCE=1" if RbConfig::CONFIG["host_os"].downcase =~ /mingw/
|
6
|
-
t.cflags << "-arch x86_64 -arch i386" if t.platform.mac?
|
7
|
-
t.ldflags << "-arch x86_64 -arch i386" if t.platform.mac?
|
8
|
-
|
9
|
-
# Link to OpenSSL
|
10
|
-
if FFI::Platform.windows?
|
11
|
-
path = File.dirname(ENV["OPENSSL_CONF"])
|
12
|
-
path = File.expand_path("../", path)
|
13
|
-
t.cflags << "-I \"#{path}/include\""
|
14
|
-
t.ldflags << "-L\"#{path}/lib\" -lssleay32 -llibeay32"
|
15
|
-
else
|
16
|
-
t.ldflags << "-lssl -lcrypto"
|
17
|
-
end
|
18
|
-
end
|
1
|
+
require 'ffi-compiler/compile_task'
|
2
|
+
|
3
|
+
FFI::Compiler::CompileTask.new('ruby-tls-ext') do |t|
|
4
|
+
t.cflags << "-Wall -Wextra -O3"
|
5
|
+
t.cflags << "-D_GNU_SOURCE=1" if RbConfig::CONFIG["host_os"].downcase =~ /mingw/
|
6
|
+
t.cflags << "-arch x86_64 -arch i386" if t.platform.mac?
|
7
|
+
t.ldflags << "-arch x86_64 -arch i386" if t.platform.mac?
|
8
|
+
|
9
|
+
# Link to OpenSSL
|
10
|
+
if FFI::Platform.windows?
|
11
|
+
path = File.dirname(ENV["OPENSSL_CONF"])
|
12
|
+
path = File.expand_path("../", path)
|
13
|
+
t.cflags << "-I \"#{path}/include\""
|
14
|
+
t.ldflags << "-L\"#{path}/lib\" -lssleay32 -llibeay32"
|
15
|
+
else
|
16
|
+
t.ldflags << "-lssl -lcrypto"
|
17
|
+
end
|
18
|
+
end
|
data/ext/tls/page.cpp
CHANGED
@@ -1,102 +1,102 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: page.cpp
|
6
|
-
Date: 30Apr06
|
7
|
-
|
8
|
-
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
-
Gmail: blackhedd
|
10
|
-
|
11
|
-
This program is free software; you can redistribute it and/or modify
|
12
|
-
it under the terms of either: 1) the GNU General Public License
|
13
|
-
as published by the Free Software Foundation; either version 2 of the
|
14
|
-
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
-
|
16
|
-
See the file COPYING for complete licensing information.
|
17
|
-
|
18
|
-
*****************************************************************************/
|
19
|
-
|
20
|
-
|
21
|
-
#include "page.h"
|
22
|
-
|
23
|
-
|
24
|
-
/******************
|
25
|
-
PageList::PageList
|
26
|
-
******************/
|
27
|
-
|
28
|
-
PageList::PageList()
|
29
|
-
{
|
30
|
-
}
|
31
|
-
|
32
|
-
|
33
|
-
/*******************
|
34
|
-
PageList::~PageList
|
35
|
-
*******************/
|
36
|
-
|
37
|
-
PageList::~PageList()
|
38
|
-
{
|
39
|
-
while (HasPages())
|
40
|
-
PopFront();
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
/***************
|
45
|
-
PageList::Front
|
46
|
-
***************/
|
47
|
-
|
48
|
-
void PageList::Front (const char **page, int *length)
|
49
|
-
{
|
50
|
-
assert (page && length);
|
51
|
-
|
52
|
-
if (HasPages()) {
|
53
|
-
Page p = Pages.front();
|
54
|
-
*page = p.Buffer;
|
55
|
-
*length = p.Size;
|
56
|
-
}
|
57
|
-
else {
|
58
|
-
*page = NULL;
|
59
|
-
*length = 0;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
/******************
|
65
|
-
PageList::PopFront
|
66
|
-
******************/
|
67
|
-
|
68
|
-
void PageList::PopFront()
|
69
|
-
{
|
70
|
-
if (HasPages()) {
|
71
|
-
Page p = Pages.front();
|
72
|
-
Pages.pop_front();
|
73
|
-
if (p.Buffer)
|
74
|
-
free ((void*)p.Buffer);
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
|
79
|
-
/******************
|
80
|
-
PageList::HasPages
|
81
|
-
******************/
|
82
|
-
|
83
|
-
bool PageList::HasPages()
|
84
|
-
{
|
85
|
-
return (Pages.size() > 0) ? true : false;
|
86
|
-
}
|
87
|
-
|
88
|
-
|
89
|
-
/**************
|
90
|
-
PageList::Push
|
91
|
-
**************/
|
92
|
-
|
93
|
-
void PageList::Push (const char *buf, int size)
|
94
|
-
{
|
95
|
-
if (buf && (size > 0)) {
|
96
|
-
char *copy = (char*) malloc (size);
|
97
|
-
if (!copy)
|
98
|
-
throw runtime_error ("no memory in pagelist");
|
99
|
-
memcpy (copy, buf, size);
|
100
|
-
Pages.push_back (Page (copy, size));
|
101
|
-
}
|
102
|
-
}
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id$
|
4
|
+
|
5
|
+
File: page.cpp
|
6
|
+
Date: 30Apr06
|
7
|
+
|
8
|
+
Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
9
|
+
Gmail: blackhedd
|
10
|
+
|
11
|
+
This program is free software; you can redistribute it and/or modify
|
12
|
+
it under the terms of either: 1) the GNU General Public License
|
13
|
+
as published by the Free Software Foundation; either version 2 of the
|
14
|
+
License, or (at your option) any later version; or 2) Ruby's License.
|
15
|
+
|
16
|
+
See the file COPYING for complete licensing information.
|
17
|
+
|
18
|
+
*****************************************************************************/
|
19
|
+
|
20
|
+
|
21
|
+
#include "page.h"
|
22
|
+
|
23
|
+
|
24
|
+
/******************
|
25
|
+
PageList::PageList
|
26
|
+
******************/
|
27
|
+
|
28
|
+
PageList::PageList()
|
29
|
+
{
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
/*******************
|
34
|
+
PageList::~PageList
|
35
|
+
*******************/
|
36
|
+
|
37
|
+
PageList::~PageList()
|
38
|
+
{
|
39
|
+
while (HasPages())
|
40
|
+
PopFront();
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
/***************
|
45
|
+
PageList::Front
|
46
|
+
***************/
|
47
|
+
|
48
|
+
void PageList::Front (const char **page, int *length)
|
49
|
+
{
|
50
|
+
assert (page && length);
|
51
|
+
|
52
|
+
if (HasPages()) {
|
53
|
+
Page p = Pages.front();
|
54
|
+
*page = p.Buffer;
|
55
|
+
*length = p.Size;
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
*page = NULL;
|
59
|
+
*length = 0;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
/******************
|
65
|
+
PageList::PopFront
|
66
|
+
******************/
|
67
|
+
|
68
|
+
void PageList::PopFront()
|
69
|
+
{
|
70
|
+
if (HasPages()) {
|
71
|
+
Page p = Pages.front();
|
72
|
+
Pages.pop_front();
|
73
|
+
if (p.Buffer)
|
74
|
+
free ((void*)p.Buffer);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
/******************
|
80
|
+
PageList::HasPages
|
81
|
+
******************/
|
82
|
+
|
83
|
+
bool PageList::HasPages()
|
84
|
+
{
|
85
|
+
return (Pages.size() > 0) ? true : false;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
/**************
|
90
|
+
PageList::Push
|
91
|
+
**************/
|
92
|
+
|
93
|
+
void PageList::Push (const char *buf, int size)
|
94
|
+
{
|
95
|
+
if (buf && (size > 0)) {
|
96
|
+
char *copy = (char*) malloc (size);
|
97
|
+
if (!copy)
|
98
|
+
throw runtime_error ("no memory in pagelist");
|
99
|
+
memcpy (copy, buf, size);
|
100
|
+
Pages.push_back (Page (copy, size));
|
101
|
+
}
|
102
|
+
}
|