ruby-libstorj 0.0.0
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 +7 -0
- data/.gitignore +10 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +111 -0
- data/Guardfile +21 -0
- data/LICENSE +502 -0
- data/README.md +262 -0
- data/Rakefile +76 -0
- data/ext/libstorj/.gitignore +47 -0
- data/ext/libstorj/.travis.yml +27 -0
- data/ext/libstorj/Doxyfile +2427 -0
- data/ext/libstorj/LICENSE +502 -0
- data/ext/libstorj/Makefile.am +6 -0
- data/ext/libstorj/README.md +198 -0
- data/ext/libstorj/autogen.sh +3 -0
- data/ext/libstorj/configure.ac +64 -0
- data/ext/libstorj/depends/Makefile +153 -0
- data/ext/libstorj/depends/config.guess +1462 -0
- data/ext/libstorj/depends/config.sub +1823 -0
- data/ext/libstorj/depends/extract-osx-sdk.sh +33 -0
- data/ext/libstorj/depends/packages/cctools.mk +7 -0
- data/ext/libstorj/depends/packages/clang.mk +7 -0
- data/ext/libstorj/depends/packages/gmp.mk +23 -0
- data/ext/libstorj/depends/packages/gnutls.mk +25 -0
- data/ext/libstorj/depends/packages/json-c.mk +7 -0
- data/ext/libstorj/depends/packages/libcurl.mk +39 -0
- data/ext/libstorj/depends/packages/libmicrohttpd.mk +7 -0
- data/ext/libstorj/depends/packages/libuv.mk +7 -0
- data/ext/libstorj/depends/packages/nettle.mk +30 -0
- data/ext/libstorj/libstorj.pc.in +11 -0
- data/ext/libstorj/src/Makefile.am +23 -0
- data/ext/libstorj/src/bip39.c +233 -0
- data/ext/libstorj/src/bip39.h +64 -0
- data/ext/libstorj/src/bip39_english.h +2074 -0
- data/ext/libstorj/src/cli.c +1494 -0
- data/ext/libstorj/src/crypto.c +525 -0
- data/ext/libstorj/src/crypto.h +178 -0
- data/ext/libstorj/src/downloader.c +1923 -0
- data/ext/libstorj/src/downloader.h +163 -0
- data/ext/libstorj/src/http.c +688 -0
- data/ext/libstorj/src/http.h +175 -0
- data/ext/libstorj/src/rs.c +962 -0
- data/ext/libstorj/src/rs.h +99 -0
- data/ext/libstorj/src/storj.c +1523 -0
- data/ext/libstorj/src/storj.h +1014 -0
- data/ext/libstorj/src/uploader.c +2736 -0
- data/ext/libstorj/src/uploader.h +181 -0
- data/ext/libstorj/src/utils.c +336 -0
- data/ext/libstorj/src/utils.h +65 -0
- data/ext/libstorj/test/Makefile.am +27 -0
- data/ext/libstorj/test/mockbridge.c +260 -0
- data/ext/libstorj/test/mockbridge.json +687 -0
- data/ext/libstorj/test/mockbridgeinfo.json +1836 -0
- data/ext/libstorj/test/mockfarmer.c +358 -0
- data/ext/libstorj/test/storjtests.h +41 -0
- data/ext/libstorj/test/tests.c +1617 -0
- data/ext/libstorj/test/tests_rs.c +869 -0
- data/ext/ruby-libstorj/extconf.rb +8 -0
- data/ext/ruby-libstorj/ruby-libstorj.cc +17 -0
- data/lib/ruby-libstorj.rb +1 -0
- data/lib/ruby-libstorj/arg_forwarding_task.rb +58 -0
- data/lib/ruby-libstorj/env.rb +178 -0
- data/lib/ruby-libstorj/ext/bucket.rb +71 -0
- data/lib/ruby-libstorj/ext/create_bucket_request.rb +53 -0
- data/lib/ruby-libstorj/ext/curl_code.rb +139 -0
- data/lib/ruby-libstorj/ext/ext.rb +71 -0
- data/lib/ruby-libstorj/ext/file.rb +84 -0
- data/lib/ruby-libstorj/ext/get_bucket_request.rb +45 -0
- data/lib/ruby-libstorj/ext/json_request.rb +51 -0
- data/lib/ruby-libstorj/ext/list_files_request.rb +63 -0
- data/lib/ruby-libstorj/ext/types.rb +226 -0
- data/lib/ruby-libstorj/ext/upload_options.rb +38 -0
- data/lib/ruby-libstorj/libstorj.rb +22 -0
- data/lib/ruby-libstorj/mixins/storj.rb +27 -0
- data/lib/ruby-libstorj/struct.rb +42 -0
- data/ruby-libstorj.gemspec +57 -0
- data/spec/helpers/options.yml.example +22 -0
- data/spec/helpers/shared_rake_examples.rb +132 -0
- data/spec/helpers/storj_options.rb +96 -0
- data/spec/helpers/upload.data +3 -0
- data/spec/helpers/upload.data.sha256 +1 -0
- data/spec/libstorj_spec.rb +0 -0
- data/spec/ruby-libstorj/arg_forwarding_task_spec.rb +311 -0
- data/spec/ruby-libstorj/env_spec.rb +353 -0
- data/spec/ruby-libstorj/ext_spec.rb +75 -0
- data/spec/ruby-libstorj/json_request_spec.rb +13 -0
- data/spec/ruby-libstorj/libstorj_spec.rb +81 -0
- data/spec/ruby-libstorj/struct_spec.rb +64 -0
- data/spec/spec_helper.rb +113 -0
- metadata +136 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include <string.h>
|
|
2
|
+
#include <storj.h>
|
|
3
|
+
|
|
4
|
+
using namespace std;
|
|
5
|
+
|
|
6
|
+
extern "C"
|
|
7
|
+
void Init_ruby_libstorj(void) {
|
|
8
|
+
/*
|
|
9
|
+
* Experiment here...
|
|
10
|
+
*
|
|
11
|
+
* the goal of this implementation is to use ruby FFI
|
|
12
|
+
* as much as possible for better compatibility/support
|
|
13
|
+
* as well as more accessibility from the ruby side
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// printf("C: hello from `Init_ruby_libstorj`!");
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'ruby-libstorj/libstorj'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# NB: ArgForwardingTask allows aliasing of rake tasks
|
|
2
|
+
# while also forwarding arguments. We're using it here to allow
|
|
3
|
+
# the tasks, "spec", and "test" work identically
|
|
4
|
+
module LibStorj
|
|
5
|
+
require 'rake'
|
|
6
|
+
|
|
7
|
+
class ArgForwardingTask
|
|
8
|
+
include Rake::DSL
|
|
9
|
+
|
|
10
|
+
attr_reader :target_task
|
|
11
|
+
attr_reader :alias_tasks
|
|
12
|
+
|
|
13
|
+
def initialize(target_name, alias_names: [nil], args_deps_hash:, &block)
|
|
14
|
+
@alias_tasks = {}
|
|
15
|
+
@target_task = nil
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if alias_names.nil? || alias_names.empty? || alias_names.reject {|t| !t}.empty?
|
|
19
|
+
unless block
|
|
20
|
+
throw ArgumentError.new 'either a block or at least one alias is required for `ArgFowardingTask.new`'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
block_wrapper = Proc.new do |task, args|
|
|
24
|
+
deps = args_deps_hash.values.flatten
|
|
25
|
+
yield task, args, deps
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# if no aliases, just register the target
|
|
29
|
+
#
|
|
30
|
+
#:call-seq:
|
|
31
|
+
# ... v-- We're using this signature --v
|
|
32
|
+
# Rake::Task.define_task task_name, arguments => dependencies
|
|
33
|
+
#(see https://github.com/ruby/rake/blob/68ef9140c11d083d8bb7ee5da5b0543e3a7df73d/lib/rake/dsl_definition.rb#L28)
|
|
34
|
+
@target_task = task(target_name, args_deps_hash, &block_wrapper)
|
|
35
|
+
else
|
|
36
|
+
if block_given?
|
|
37
|
+
block_wrapper = Proc.new do |task, args|
|
|
38
|
+
deps = args_deps_hash.values.flatten
|
|
39
|
+
yield task, args, deps
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@target_task = task(target_name, args_deps_hash, &block_wrapper)
|
|
43
|
+
else
|
|
44
|
+
@target_task = task(target_name, args_deps_hash)
|
|
45
|
+
end
|
|
46
|
+
alias_names.flatten.each do |task_name|
|
|
47
|
+
@alias_tasks[task_name] = task(task_name, args_deps_hash) do |t, args|
|
|
48
|
+
@target_task.invoke(*args.to_a)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def method_missing(name, *args, &block)
|
|
55
|
+
@target_task.method(name).call(*args, &block)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
module LibStorj
|
|
2
|
+
class Env
|
|
3
|
+
require 'libuv'
|
|
4
|
+
require 'json'
|
|
5
|
+
attr_reader :storj_env
|
|
6
|
+
|
|
7
|
+
C_ANALOGUE = ::LibStorj::Ext::Storj::Env
|
|
8
|
+
|
|
9
|
+
def initialize(*options)
|
|
10
|
+
@storj_env = ::LibStorj::Ext::Storj.method(:init_env).call(*options)
|
|
11
|
+
# use ruby libuv's default_loop
|
|
12
|
+
@storj_env[:loop] = ::Libuv::Ext.default_loop
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def destroy
|
|
16
|
+
::LibStorj::Ext::Storj.destroy_env @storj_env
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get_info(&block)
|
|
20
|
+
ruby_handle = ::LibStorj::Ext::Storj::JsonRequest.ruby_handle(&block)
|
|
21
|
+
after_work_cb = ::LibStorj::Ext::Storj::JsonRequest.after_work_cb do |error|
|
|
22
|
+
yield error if block_given?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# calls uv_queue_work
|
|
26
|
+
status = ::LibStorj::Ext::Storj.get_info @storj_env,
|
|
27
|
+
ruby_handle,
|
|
28
|
+
after_work_cb
|
|
29
|
+
reactor.run # calls uv_run
|
|
30
|
+
status
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def delete_bucket(bucket_id, &block)
|
|
34
|
+
req_data_type = ::LibStorj::Ext::Storj::JsonRequest
|
|
35
|
+
after_work_cb = req_data_type.after_work_cb
|
|
36
|
+
ruby_handle = req_data_type.ruby_handle do |error|
|
|
37
|
+
yield error if block_given?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# calls uv_queue_work
|
|
41
|
+
status = ::LibStorj::Ext::Storj::Bucket.delete @storj_env,
|
|
42
|
+
bucket_id,
|
|
43
|
+
ruby_handle,
|
|
44
|
+
after_work_cb
|
|
45
|
+
reactor.run # calls uv_run
|
|
46
|
+
status
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_buckets(&block)
|
|
50
|
+
req_data_type = ::LibStorj::Ext::Storj::GetBucketRequest
|
|
51
|
+
after_work_cb = req_data_type.after_work_cb
|
|
52
|
+
ruby_handle = req_data_type.ruby_handle(&block)
|
|
53
|
+
|
|
54
|
+
# calls uv_queue_work
|
|
55
|
+
status = ::LibStorj::Ext::Storj::Bucket.all @storj_env,
|
|
56
|
+
ruby_handle,
|
|
57
|
+
after_work_cb
|
|
58
|
+
reactor.run # calls uv_run
|
|
59
|
+
status
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def create_bucket(name, &block)
|
|
63
|
+
req_data_type = ::LibStorj::Ext::Storj::CreateBucketRequest
|
|
64
|
+
after_work_cb = req_data_type.after_work_cb
|
|
65
|
+
ruby_handle = req_data_type.ruby_handle(&block)
|
|
66
|
+
|
|
67
|
+
# calls uv_queue_work
|
|
68
|
+
status = ::LibStorj::Ext::Storj::Bucket.create @storj_env,
|
|
69
|
+
name,
|
|
70
|
+
ruby_handle,
|
|
71
|
+
after_work_cb
|
|
72
|
+
reactor.run # calls uv_run
|
|
73
|
+
status
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def list_files(bucket_id, &block)
|
|
77
|
+
req_data_type = ::LibStorj::Ext::Storj::ListFilesRequest
|
|
78
|
+
after_work_cb = req_data_type.after_work_cb
|
|
79
|
+
ruby_handle = req_data_type.ruby_handle(&block)
|
|
80
|
+
|
|
81
|
+
status = ::LibStorj::Ext::Storj::File.all @storj_env,
|
|
82
|
+
bucket_id,
|
|
83
|
+
ruby_handle,
|
|
84
|
+
after_work_cb
|
|
85
|
+
reactor.run # calls uv_run
|
|
86
|
+
status
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def delete_file(bucket_id, file_id, &block)
|
|
90
|
+
req_data_type = ::LibStorj::Ext::Storj::JsonRequest
|
|
91
|
+
after_work_cb = req_data_type.after_work_cb
|
|
92
|
+
ruby_handle = req_data_type.ruby_handle(&block)
|
|
93
|
+
|
|
94
|
+
# calls uv_queue_work
|
|
95
|
+
status = ::LibStorj::Ext::Storj::File.delete @storj_env,
|
|
96
|
+
bucket_id,
|
|
97
|
+
file_id,
|
|
98
|
+
ruby_handle,
|
|
99
|
+
after_work_cb
|
|
100
|
+
reactor.run # calls uv_run
|
|
101
|
+
status
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def resolve_file(bucket_id:,
|
|
105
|
+
file_id:,
|
|
106
|
+
file_path:,
|
|
107
|
+
progress_proc: nil,
|
|
108
|
+
finished_proc: nil,
|
|
109
|
+
&block)
|
|
110
|
+
file_descriptor = ::LibStorj::Ext::LibC.fopen(file_path, 'w+')
|
|
111
|
+
progress_cb = FFI::Function.new :void, %i[double uint64 uint64 pointer] do
|
|
112
|
+
|progress, downloaded_bytes, total_bytes, handle|
|
|
113
|
+
progress_proc.call progress, downloaded_bytes, total_bytes if progress_proc
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# TODO: decide precedence
|
|
117
|
+
finished_proc = finished_proc || block
|
|
118
|
+
finished_cb = FFI::Function.new :void, %i[int pointer pointer] do |status, file_id, handle|
|
|
119
|
+
# do error handling based on status
|
|
120
|
+
::LibStorj::Ext::LibC.fclose(file_descriptor)
|
|
121
|
+
finished_proc.call file_id
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# ruby_handle = FFI::MemoryPointer::NULL
|
|
125
|
+
ruby_handle = FFI::Function.new :void, [] do
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# calls uv_queue_work
|
|
129
|
+
state = ::LibStorj::Ext::Storj::File.resolve @storj_env,
|
|
130
|
+
bucket_id,
|
|
131
|
+
file_id,
|
|
132
|
+
file_descriptor,
|
|
133
|
+
ruby_handle,
|
|
134
|
+
progress_cb,
|
|
135
|
+
finished_cb
|
|
136
|
+
reactor.run # calls uv_run
|
|
137
|
+
state
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def store_file(bucket_id:,
|
|
141
|
+
file_path:,
|
|
142
|
+
progress_proc: nil,
|
|
143
|
+
finished_proc: nil,
|
|
144
|
+
options: {},
|
|
145
|
+
&block)
|
|
146
|
+
default_options = {
|
|
147
|
+
bucket_id: bucket_id,
|
|
148
|
+
file_path: file_path,
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
options = options.merge(default_options) {|key, oldval| oldval}
|
|
152
|
+
upload_options =
|
|
153
|
+
::LibStorj::Ext::Storj::UploadOptions.new options
|
|
154
|
+
|
|
155
|
+
progress_cb = FFI::Function.new :void, %i[double uint64 uint64 pointer] do
|
|
156
|
+
|progress, bytes, total_bytes|
|
|
157
|
+
progress_proc.call progress, bytes, total_bytes if progress_proc
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
#TODO: decide precedence
|
|
161
|
+
finished_proc = finished_proc || block
|
|
162
|
+
finished_cb = FFI::Function.new :void, %i[int string pointer] do
|
|
163
|
+
|status, file_id, handle|
|
|
164
|
+
# do error handling based on status
|
|
165
|
+
finished_proc.call file_id
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# calls uv_queue_work
|
|
169
|
+
state = ::LibStorj::Ext::Storj::File.store @storj_env,
|
|
170
|
+
upload_options,
|
|
171
|
+
FFI::MemoryPointer::NULL,
|
|
172
|
+
progress_cb,
|
|
173
|
+
finished_cb
|
|
174
|
+
reactor.run #calls uv_run
|
|
175
|
+
state
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module LibStorj
|
|
2
|
+
module Ext
|
|
3
|
+
module Storj
|
|
4
|
+
class Bucket < FFI::Struct
|
|
5
|
+
extend FFI::Library
|
|
6
|
+
ffi_lib('storj')
|
|
7
|
+
|
|
8
|
+
attr_reader :name, :id
|
|
9
|
+
|
|
10
|
+
def initialize(*args)
|
|
11
|
+
super(*args)
|
|
12
|
+
|
|
13
|
+
@name = self[:name]
|
|
14
|
+
@id = self[:id]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.all(*args)
|
|
18
|
+
_all(*args)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.create(*args)
|
|
22
|
+
_create(*args)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.delete(*args)
|
|
26
|
+
_delete(*args)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.pointer_to_array(pointer, array_length)
|
|
30
|
+
if pointer.nil? || pointer == FFI::MemoryPointer::NULL || array_length < 1
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
### #=> [#<LibStorj::Ext::Storj::Bucket ...>, ...]
|
|
35
|
+
(0..(array_length - 1)).map do |i|
|
|
36
|
+
Bucket.new pointer[i * size]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
attach_function('_all', 'storj_bridge_get_buckets', [
|
|
41
|
+
Env.by_ref,
|
|
42
|
+
::LibStorj::Ext::Storj::JsonRequest::CALLBACK,
|
|
43
|
+
:pointer # uv_after_work_cb*
|
|
44
|
+
# ::LibStorj::UV::
|
|
45
|
+
], :int)
|
|
46
|
+
|
|
47
|
+
private :_all
|
|
48
|
+
|
|
49
|
+
attach_function('_create', 'storj_bridge_create_bucket', [
|
|
50
|
+
Env.by_ref,
|
|
51
|
+
:string,
|
|
52
|
+
::LibStorj::Ext::Storj::JsonRequest::CALLBACK,
|
|
53
|
+
:pointer # uv_after_work_cb*
|
|
54
|
+
# ::LibStorj::UV::
|
|
55
|
+
], :int)
|
|
56
|
+
|
|
57
|
+
private :_create
|
|
58
|
+
|
|
59
|
+
attach_function('_delete', 'storj_bridge_delete_bucket', [
|
|
60
|
+
Env.by_ref,
|
|
61
|
+
:string,
|
|
62
|
+
::LibStorj::Ext::Storj::JsonRequest::CALLBACK,
|
|
63
|
+
:pointer # uv_after_work_cb*
|
|
64
|
+
# ::LibStorj::UV::
|
|
65
|
+
], :int)
|
|
66
|
+
|
|
67
|
+
private :_delete
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module LibStorj
|
|
2
|
+
module Ext
|
|
3
|
+
module Storj
|
|
4
|
+
class CreateBucketRequest < FFI::Struct
|
|
5
|
+
layout :http_options, HttpOptions.by_ref,
|
|
6
|
+
:encrypt_options, EncryptOptions.by_ref,
|
|
7
|
+
:bridge_options, BridgeOptions.by_ref,
|
|
8
|
+
:bucket_name, :string,
|
|
9
|
+
:encrypted_bucket_name, :string,
|
|
10
|
+
:response, :pointer, # struct json_object *response;
|
|
11
|
+
:bucket, Bucket.by_ref,
|
|
12
|
+
:error_code, :int,
|
|
13
|
+
:status_code, :int,
|
|
14
|
+
:handle, :pointer # void*
|
|
15
|
+
|
|
16
|
+
def self.after_work_cb
|
|
17
|
+
args = [::LibStorj::Ext::UV::Work.by_ref, :int]
|
|
18
|
+
|
|
19
|
+
FFI::Function.new :void, args do |work_req_ptr|
|
|
20
|
+
req = new work_req_ptr[:data]
|
|
21
|
+
response = ::LibStorj::Ext::JsonC.stringify req[:response]
|
|
22
|
+
error = ::LibStorj::Ext::Curl.curl_code_to_string req[:error_code]
|
|
23
|
+
c_handle = FFI::Function.new :void, %i[string pointer], req[:handle]
|
|
24
|
+
|
|
25
|
+
next c_handle.call(error, ::FFI::MemoryPointer::NULL) unless error.empty?
|
|
26
|
+
|
|
27
|
+
status_code, bucket = req.values_at %i[status_code bucket]
|
|
28
|
+
if ((status_code > 299) || bucket.id.nil?) && error.empty?
|
|
29
|
+
response_error = JSON.parse(response)['error']
|
|
30
|
+
error = response_error
|
|
31
|
+
next c_handle.call(error, ::FFI::MemoryPointer::NULL)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
bucket_pointer = req[:bucket]
|
|
35
|
+
c_handle.call nil, bucket_pointer
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.ruby_handle(&block)
|
|
40
|
+
FFI::Function.new :void, %i[string pointer] do |error, bucket_pointer|
|
|
41
|
+
bucket = if bucket_pointer.null?
|
|
42
|
+
nil
|
|
43
|
+
else
|
|
44
|
+
::LibStorj::Ext::Storj::Bucket.new(bucket_pointer)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
yield error, bucket if block_given?
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
module LibStorj
|
|
2
|
+
module Ext
|
|
3
|
+
module Curl
|
|
4
|
+
CURL_CODES = [
|
|
5
|
+
# /* All possible error codes from all sorts of curl functions. Future versions
|
|
6
|
+
# may return other values, stay prepared.
|
|
7
|
+
#
|
|
8
|
+
# Always add new return codes last. Never *EVER* remove any. The return
|
|
9
|
+
# codes must remain the same!
|
|
10
|
+
# */
|
|
11
|
+
#
|
|
12
|
+
:CURLE_OK, 0,
|
|
13
|
+
:CURLE_UNSUPPORTED_PROTOCOL, #/* 1 */
|
|
14
|
+
:CURLE_FAILED_INIT, #/* 2 */
|
|
15
|
+
:CURLE_URL_MALFORMAT, #/* 3 */
|
|
16
|
+
:CURLE_NOT_BUILT_IN, #/* 4 - [was obsoleted in August 2007 for
|
|
17
|
+
# 7.17.0, reused in April 2011 for 7.21.5] */
|
|
18
|
+
:CURLE_COULDNT_RESOLVE_PROXY, #/* 5 */
|
|
19
|
+
:CURLE_COULDNT_RESOLVE_HOST, #/* 6 */
|
|
20
|
+
:CURLE_COULDNT_CONNECT, #/* 7 */
|
|
21
|
+
:CURLE_WEIRD_SERVER_REPLY, #/* 8 */
|
|
22
|
+
:CURLE_REMOTE_ACCESS_DENIED, #/* 9 a service was denied by the server
|
|
23
|
+
# due to lack of access - when login fails
|
|
24
|
+
# this is not returned. */
|
|
25
|
+
:CURLE_FTP_ACCEPT_FAILED, #/* 10 - [was obsoleted in April 2006 for
|
|
26
|
+
# 7.15.4, reused in Dec 2011 for 7.24.0]*/
|
|
27
|
+
:CURLE_FTP_WEIRD_PASS_REPLY, #/* 11 */
|
|
28
|
+
:CURLE_FTP_ACCEPT_TIMEOUT, #/* 12 - timeout occurred accepting server
|
|
29
|
+
# [was obsoleted in August 2007 for 7.17.0,
|
|
30
|
+
# reused in Dec 2011 for 7.24.0]*/
|
|
31
|
+
:CURLE_FTP_WEIRD_PASV_REPLY, #/* 13 */
|
|
32
|
+
:CURLE_FTP_WEIRD_227_FORMAT, #/* 14 */
|
|
33
|
+
:CURLE_FTP_CANT_GET_HOST, #/* 15 */
|
|
34
|
+
:CURLE_HTTP2, #/* 16 - A problem in the http2 framing layer.
|
|
35
|
+
# [was obsoleted in August 2007 for 7.17.0,
|
|
36
|
+
# reused in July 2014 for 7.38.0] */
|
|
37
|
+
:CURLE_FTP_COULDNT_SET_TYPE, #/* 17 */
|
|
38
|
+
:CURLE_PARTIAL_FILE, #/* 18 */
|
|
39
|
+
:CURLE_FTP_COULDNT_RETR_FILE, #/* 19 */
|
|
40
|
+
:CURLE_OBSOLETE20, #/* 20 - NOT USED */
|
|
41
|
+
:CURLE_QUOTE_ERROR, #/* 21 - quote command failure */
|
|
42
|
+
:CURLE_HTTP_RETURNED_ERROR, #/* 22 */
|
|
43
|
+
:CURLE_WRITE_ERROR, #/* 23 */
|
|
44
|
+
:CURLE_OBSOLETE24, #/* 24 - NOT USED */
|
|
45
|
+
:CURLE_UPLOAD_FAILED, #/* 25 - failed upload "command" */
|
|
46
|
+
:CURLE_READ_ERROR, #/* 26 - couldn't open/read from file */
|
|
47
|
+
:CURLE_OUT_OF_MEMORY, #/* 27 */
|
|
48
|
+
# /* Note: CURLE_OUT_OF_MEMORY may sometimes indicate a conversion error
|
|
49
|
+
# instead of a memory allocation error if CURL_DOES_CONVERSIONS
|
|
50
|
+
# is defined
|
|
51
|
+
# */
|
|
52
|
+
:CURLE_OPERATION_TIMEDOUT, #/* 28 - the timeout time was reached */
|
|
53
|
+
:CURLE_OBSOLETE29, #/* 29 - NOT USED */
|
|
54
|
+
:CURLE_FTP_PORT_FAILED, #/* 30 - FTP PORT operation failed */
|
|
55
|
+
:CURLE_FTP_COULDNT_USE_REST, #/* 31 - the REST command failed */
|
|
56
|
+
:CURLE_OBSOLETE32, #/* 32 - NOT USED */
|
|
57
|
+
:CURLE_RANGE_ERROR, #/* 33 - RANGE "command" didn't work */
|
|
58
|
+
:CURLE_HTTP_POST_ERROR, #/* 34 */
|
|
59
|
+
:CURLE_SSL_CONNECT_ERROR, #/* 35 - wrong when connecting with SSL */
|
|
60
|
+
:CURLE_BAD_DOWNLOAD_RESUME, #/* 36 - couldn't resume download */
|
|
61
|
+
:CURLE_FILE_COULDNT_READ_FILE, #/* 37 */
|
|
62
|
+
:CURLE_LDAP_CANNOT_BIND, #/* 38 */
|
|
63
|
+
:CURLE_LDAP_SEARCH_FAILED, #/* 39 */
|
|
64
|
+
:CURLE_OBSOLETE40, #/* 40 - NOT USED */
|
|
65
|
+
:CURLE_FUNCTION_NOT_FOUND, #/* 41 */
|
|
66
|
+
:CURLE_ABORTED_BY_CALLBACK, #/* 42 */
|
|
67
|
+
:CURLE_BAD_FUNCTION_ARGUMENT, #/* 43 */
|
|
68
|
+
:CURLE_OBSOLETE44, #/* 44 - NOT USED */
|
|
69
|
+
:CURLE_INTERFACE_FAILED, #/* 45 - CURLOPT_INTERFACE failed */
|
|
70
|
+
:CURLE_OBSOLETE46, #/* 46 - NOT USED */
|
|
71
|
+
:CURLE_TOO_MANY_REDIRECTS, #/* 47 - catch endless re-direct loops */
|
|
72
|
+
:CURLE_UNKNOWN_OPTION, #/* 48 - User specified an unknown option */
|
|
73
|
+
:CURLE_TELNET_OPTION_SYNTAX, #/* 49 - Malformed telnet option */
|
|
74
|
+
:CURLE_OBSOLETE50, #/* 50 - NOT USED */
|
|
75
|
+
:CURLE_PEER_FAILED_VERIFICATION,# /* 51 - peer's certificate or fingerprint
|
|
76
|
+
# wasn't verified fine */
|
|
77
|
+
:CURLE_GOT_NOTHING, #/* 52 - when this is a specific error */
|
|
78
|
+
:CURLE_SSL_ENGINE_NOTFOUND, #/* 53 - SSL crypto engine not found */
|
|
79
|
+
:CURLE_SSL_ENGINE_SETFAILED, #/* 54 - can not set SSL crypto engine as
|
|
80
|
+
# default */
|
|
81
|
+
:CURLE_SEND_ERROR, #/* 55 - failed sending network data */
|
|
82
|
+
:CURLE_RECV_ERROR, #/* 56 - failure in receiving network data */
|
|
83
|
+
:CURLE_OBSOLETE57, #/* 57 - NOT IN USE */
|
|
84
|
+
:CURLE_SSL_CERTPROBLEM, #/* 58 - problem with the local certificate */
|
|
85
|
+
:CURLE_SSL_CIPHER, #/* 59 - couldn't use specified cipher */
|
|
86
|
+
:CURLE_SSL_CACERT, #/* 60 - problem with the CA cert (path?) */
|
|
87
|
+
:CURLE_BAD_CONTENT_ENCODING, #/* 61 - Unrecognized/bad encoding */
|
|
88
|
+
:CURLE_LDAP_INVALID_URL, #/* 62 - Invalid LDAP URL */
|
|
89
|
+
:CURLE_FILESIZE_EXCEEDED, #/* 63 - Maximum file size exceeded */
|
|
90
|
+
:CURLE_USE_SSL_FAILED, #/* 64 - Requested FTP SSL level failed */
|
|
91
|
+
:CURLE_SEND_FAIL_REWIND, #/* 65 - Sending the data requires a rewind
|
|
92
|
+
# that failed */
|
|
93
|
+
:CURLE_SSL_ENGINE_INITFAILED, #/* 66 - failed to initialise ENGINE */
|
|
94
|
+
:CURLE_LOGIN_DENIED, #/* 67 - user, password or similar was not
|
|
95
|
+
# accepted and we failed to login */
|
|
96
|
+
:CURLE_TFTP_NOTFOUND, #/* 68 - file not found on server */
|
|
97
|
+
:CURLE_TFTP_PERM, #/* 69 - permission problem on server */
|
|
98
|
+
:CURLE_REMOTE_DISK_FULL, #/* 70 - out of disk space on server */
|
|
99
|
+
:CURLE_TFTP_ILLEGAL, #/* 71 - Illegal TFTP operation */
|
|
100
|
+
:CURLE_TFTP_UNKNOWNID, #/* 72 - Unknown transfer ID */
|
|
101
|
+
:CURLE_REMOTE_FILE_EXISTS, #/* 73 - File already exists */
|
|
102
|
+
:CURLE_TFTP_NOSUCHUSER, #/* 74 - No such user */
|
|
103
|
+
:CURLE_CONV_FAILED, #/* 75 - conversion failed */
|
|
104
|
+
:CURLE_CONV_REQD, #/* 76 - caller must register conversion
|
|
105
|
+
# callbacks using curl_easy_setopt options
|
|
106
|
+
# CURLOPT_CONV_FROM_NETWORK_FUNCTION,
|
|
107
|
+
# CURLOPT_CONV_TO_NETWORK_FUNCTION, and
|
|
108
|
+
# CURLOPT_CONV_FROM_UTF8_FUNCTION */
|
|
109
|
+
:CURLE_SSL_CACERT_BADFILE, #/* 77 - could not load CACERT file, missing
|
|
110
|
+
# or wrong format */
|
|
111
|
+
:CURLE_REMOTE_FILE_NOT_FOUND, #/* 78 - remote file not found */
|
|
112
|
+
:CURLE_SSH, #/* 79 - error from the SSH layer, somewhat
|
|
113
|
+
# generic so the error message will be of
|
|
114
|
+
# interest when this has happened */
|
|
115
|
+
:CURLE_SSL_SHUTDOWN_FAILED, #/* 80 - Failed to shut down the SSL
|
|
116
|
+
# connection */
|
|
117
|
+
:CURLE_AGAIN, #/* 81 - socket is not ready for send/recv,
|
|
118
|
+
# wait till it's ready and try again (Added
|
|
119
|
+
# in 7.18.2) */
|
|
120
|
+
:CURLE_SSL_CRL_BADFILE, #/* 82 - could not load CRL file, missing or
|
|
121
|
+
# wrong format (Added in 7.19.0) */
|
|
122
|
+
:CURLE_SSL_ISSUER_ERROR, #/* 83 - Issuer check failed. (Added in
|
|
123
|
+
# 7.19.0) */
|
|
124
|
+
:CURLE_FTP_PRET_FAILED, #/* 84 - a PRET command failed */
|
|
125
|
+
:CURLE_RTSP_CSEQ_ERROR, #/* 85 - mismatch of RTSP CSeq numbers */
|
|
126
|
+
:CURLE_RTSP_SESSION_ERROR, #/* 86 - mismatch of RTSP Session Ids */
|
|
127
|
+
:CURLE_FTP_BAD_FILE_LIST, #/* 87 - unable to parse FTP file list */
|
|
128
|
+
:CURLE_CHUNK_FAILED, #/* 88 - chunk callback reported error */
|
|
129
|
+
:CURLE_NO_CONNECTION_AVAILABLE, #/* 89 - No connection available, the
|
|
130
|
+
# session will be queued */
|
|
131
|
+
:CURLE_SSL_PINNEDPUBKEYNOTMATCH,#/* 90 - specified pinned public key did not
|
|
132
|
+
# match */
|
|
133
|
+
:CURLE_SSL_INVALIDCERTSTATUS, #/* 91 - invalid certificate status */
|
|
134
|
+
:CURLE_HTTP2_STREAM, #/* 92 - stream error in HTTP/2 framing layer */
|
|
135
|
+
:CURL_LAST #/* never use! */
|
|
136
|
+
]
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|