ffi-libc 0.0.1

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.
@@ -0,0 +1,4 @@
1
+ doc
2
+ pkg
3
+ .bundle
4
+ .yardoc
@@ -0,0 +1 @@
1
+ --colour --format specdoc
@@ -0,0 +1 @@
1
+ --markup markdown --title 'FFI LibC Documentation' --protected --files ChangeLog.md,LICENSE.txt
@@ -0,0 +1,60 @@
1
+ ### 0.1.0 / 2010-05-19
2
+
3
+ * Initial release.
4
+ * Added the Structs:
5
+ * {FFI::LibC::Timeval}.
6
+ * {FFI::LibC::Timezone}.
7
+ * Added the variables:
8
+ * `sys_errlist`
9
+ * `sys_nerr`
10
+ * `errno`
11
+ * Added the functions:
12
+ * `brk`
13
+ * `sbrk`
14
+ * `calloc`
15
+ * `malloc`
16
+ * `free`
17
+ * `realloc`
18
+ * `getenv`
19
+ * `putenv`
20
+ * `unsetenv`
21
+ * `clearenv`
22
+ * `time`
23
+ * `gettimeofday`
24
+ * `settimeofday`
25
+ * `mmap`
26
+ * `munmap`
27
+ * `bzero`
28
+ * `memset`
29
+ * `memcpy`
30
+ * `memcmp`
31
+ * `memchr`
32
+ * `memrchr`
33
+ * `strcpy`
34
+ * `strncpy`
35
+ * `strlen`
36
+ * `index`
37
+ * `rindex`
38
+ * `strchr`
39
+ * `strrchr`
40
+ * `strstr`
41
+ * `strerror`
42
+ * `fopen`
43
+ * `fdopen`
44
+ * `freopen`
45
+ * `fseek`
46
+ * `ftell`
47
+ * `rewind`
48
+ * `fread`
49
+ * `fwrite`
50
+ * `fgetc`
51
+ * `fgets`
52
+ * `fputc`
53
+ * `fputs`
54
+ * `fflush`
55
+ * `fclose`
56
+ * `clearerr`
57
+ * `feof`
58
+ * `ferror`
59
+ * `fileno`
60
+ * `perror`
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :runtime do
4
+ gem 'ffi', '~> 0.6.0'
5
+ end
6
+
7
+ group :development do
8
+ gem 'bundler', '~> 0.9.25'
9
+ gem 'rake', '~> 0.8.7'
10
+ gem 'jeweler', '~> 1.4.0', :git => 'git://github.com/technicalpickles/jeweler.git'
11
+ end
12
+
13
+ group :doc do
14
+ case RUBY_PLATFORM
15
+ when 'java'
16
+ gem 'maruku', '~> 0.6.0'
17
+ else
18
+ gem 'rdiscount', '~> 1.6.3'
19
+ end
20
+
21
+ gem 'yard', '~> 0.5.3'
22
+ end
23
+
24
+ gem 'rspec', '~> 1.3.0', :group => [:development, :test]
@@ -0,0 +1,23 @@
1
+
2
+ The MIT License
3
+
4
+ Copyright (c) 2010 Hal Brodigan
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # ffi-libc
2
+
3
+ * [github.com/postmodern/ffi-libc](http://github.com/postmodern/ffi-libc/)
4
+ * [github.com/postmodern/ffi-libc/issues](http://github.com/postmodern/ffi-libc/issues)
5
+ * Postmodern (postmodern.mod3 at gmail.com)
6
+
7
+ ## Description
8
+
9
+ Useful Ruby FFI bindings for `libc`.
10
+
11
+ ## Features
12
+
13
+ * Provides common Structs used in `libc`.
14
+ * Binds to common functions and global variables in `libc`.
15
+
16
+ ## Examples
17
+
18
+ ## Requirements
19
+
20
+ * [ffi](http://github.com/ffi/ffi) >= 0.6.0
21
+
22
+ ## Install
23
+
24
+ $ sudo gem install ffi-libc
25
+
26
+ ## License
27
+
28
+ See {file:LICENSE.txt} for license information.
29
+
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:development, :doc)
6
+ rescue Bundler::BundlerError => e
7
+ STDERR.puts e.message
8
+ STDERR.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+
12
+ require 'rake'
13
+ require 'rake/clean'
14
+ require 'jeweler'
15
+
16
+ Jeweler::Tasks.new do |gem|
17
+ gem.name = 'ffi-libc'
18
+ gem.licenses = ['MIT']
19
+ gem.summary = %Q{Useful FFI bindings for libc}
20
+ gem.email = 'postmodern.mod3@gmail.com'
21
+ gem.homepage = %Q{http://github.com/postmodern/ffi-libc}
22
+ gem.description = %Q{Useful Ruby FFI bindings for libc.}
23
+ gem.authors = ['Postmodern']
24
+ gem.has_rdoc = 'yard'
25
+ end
26
+
27
+ require 'spec/rake/spectask'
28
+
29
+ desc "Run all specifications"
30
+ Spec::Rake::SpecTask.new(:spec) do |spec|
31
+ spec.libs += ['lib', 'spec']
32
+ spec.spec_files = FileList['spec/**/*_spec.rb']
33
+ spec.spec_opts = ['--options', '.specopts']
34
+ end
35
+ task :default => :spec
36
+
37
+ require 'yard'
38
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ffi-libc}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Postmodern"]
12
+ s.date = %q{2010-05-19}
13
+ s.description = %q{Useful Ruby FFI bindings for libc.}
14
+ s.email = %q{postmodern.mod3@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "ChangeLog.md",
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ ".specopts",
23
+ ".yardopts",
24
+ "ChangeLog.md",
25
+ "Gemfile",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "ffi-libc.gemspec",
31
+ "lib/ffi/libc.rb",
32
+ "lib/ffi/libc/libc.rb",
33
+ "lib/ffi/libc/timeval.rb",
34
+ "lib/ffi/libc/timezone.rb",
35
+ "lib/ffi/libc/types.rb"
36
+ ]
37
+ s.has_rdoc = %q{yard}
38
+ s.homepage = %q{http://github.com/postmodern/ffi-libc}
39
+ s.licenses = ["MIT"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.7}
42
+ s.summary = %q{Useful FFI bindings for libc}
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
+ s.add_runtime_dependency(%q<ffi>, ["~> 0.6.0"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 0.9.25"])
51
+ s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 1.4.0"])
53
+ s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
54
+ else
55
+ s.add_dependency(%q<ffi>, ["~> 0.6.0"])
56
+ s.add_dependency(%q<bundler>, ["~> 0.9.25"])
57
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
59
+ s.add_dependency(%q<rspec>, ["~> 1.3.0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<ffi>, ["~> 0.6.0"])
63
+ s.add_dependency(%q<bundler>, ["~> 0.9.25"])
64
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
65
+ s.add_dependency(%q<jeweler>, ["~> 1.4.0"])
66
+ s.add_dependency(%q<rspec>, ["~> 1.3.0"])
67
+ end
68
+ end
69
+
@@ -0,0 +1,2 @@
1
+ require 'ffi/libc/types'
2
+ require 'ffi/libc/libc'
@@ -0,0 +1,81 @@
1
+ require 'ffi/libc/types'
2
+ require 'ffi/libc/timeval'
3
+ require 'ffi/libc/timezone'
4
+
5
+ require 'ffi'
6
+
7
+ module FFI
8
+ module LibC
9
+ extend FFI::Library
10
+
11
+ ffi_lib 'c'
12
+
13
+ # errno.h
14
+ attach_variable :sys_errlist, :pointer
15
+ attach_variable :sys_nerr, :int
16
+ attach_variable :errno, :int
17
+
18
+ # unistd.h
19
+ attach_function :brk, [:pointer], :int
20
+ attach_function :sbrk, [:pointer], :pointer
21
+
22
+ # stdlib.h
23
+ attach_function :calloc, [:size_t, :size_t], :pointer
24
+ attach_function :malloc, [:size_t], :pointer
25
+ attach_function :free, [:pointer], :void
26
+ attach_function :realloc, [:pointer, :size_t], :pointer
27
+ attach_function :getenv, [:string], :string
28
+ attach_function :putenv, [:string], :int
29
+ attach_function :unsetenv, [:string], :int
30
+ attach_function :clearenv, [], :int
31
+
32
+ # time.h
33
+ attach_function :time, [:pointer], :time_t
34
+
35
+ # sys/time.h
36
+ attach_function :gettimeofday, [:pointer, :pointer], :int
37
+ attach_function :settimeofday, [:pointer, :pointer], :int
38
+
39
+ # sys/mman.h
40
+ attach_function :mmap, [:pointer, :size_t, :int, :int, :int, :off_t], :pointer
41
+ attach_function :munmap, [:pointer, :size_t], :int
42
+
43
+ # string.h
44
+ attach_function :bzero, [:pointer, :size_t], :void
45
+ attach_function :memset, [:pointer, :int, :size_t], :pointer
46
+ attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
47
+ attach_function :memcmp, [:pointer, :pointer, :size_t], :int
48
+ attach_function :memchr, [:pointer, :int, :size_t], :pointer
49
+ attach_function :memrchr, [:pointer, :int, :size_t], :pointer
50
+ attach_function :strcpy, [:string, :string], :pointer
51
+ attach_function :strncpy, [:string, :string, :size_t], :pointer
52
+ attach_function :strlen, [:string], :size_t
53
+ attach_function :index, [:string, :int], :string
54
+ attach_function :rindex, [:string, :int], :string
55
+ attach_function :strchr, [:string, :int], :string
56
+ attach_function :strrchr, [:string, :int], :string
57
+ attach_function :strstr, [:string, :string], :string
58
+ attach_function :strerror, [:int], :string
59
+
60
+ # stdio.h
61
+ attach_function :fopen, [:string, :string], :FILE
62
+ attach_function :fdopen, [:int, :string], :FILE
63
+ attach_function :freopen, [:string, :string, :FILE], :FILE
64
+ attach_function :fseek, [:FILE, :long, :int], :int
65
+ attach_function :ftell, [:FILE], :long
66
+ attach_function :rewind, [:FILE], :void
67
+ attach_function :fread, [:pointer, :size_t, :size_t, :FILE], :size_t
68
+ attach_function :fwrite, [:pointer, :size_t, :size_t, :FILE], :size_t
69
+ attach_function :fgetc, [:FILE], :int
70
+ attach_function :fgets, [:pointer, :int, :FILE], :pointer
71
+ attach_function :fputc, [:int, :FILE], :int
72
+ attach_function :fputs, [:string, :FILE], :int
73
+ attach_function :fflush, [:FILE], :int
74
+ attach_function :fclose, [:FILE], :int
75
+ attach_function :clearerr, [:FILE], :void
76
+ attach_function :feof, [:FILE], :int
77
+ attach_function :ferror, [:FILE], :int
78
+ attach_function :fileno, [:FILE], :int
79
+ attach_function :perror, [:string], :void
80
+ end
81
+ end
@@ -0,0 +1,12 @@
1
+ require 'ffi/libc/types'
2
+
3
+ module FFI
4
+ module LibC
5
+ class Timeval < FFI::Struct
6
+
7
+ layout :tv_sec, :time_t,
8
+ :tv_usec, :suseconds_t
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'ffi'
2
+
3
+ module FFI
4
+ module LibC
5
+ class Timezone < FFI::Struct
6
+
7
+ layout :tz_minutewest, :int,
8
+ :tz_dsttime, :int
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ require 'ffi'
2
+
3
+ module FFI
4
+ module LibC
5
+ extend FFI::Library
6
+
7
+ typedef :uint, :size_t
8
+ typedef :int, :ssize_t
9
+ typedef :uint, :off_t
10
+ typedef :ulong, :time_t
11
+ typedef :long, :suseconds_t
12
+ typedef :pointer, :FILE
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffi-libc
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Postmodern
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-05-19 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: ffi
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 0
31
+ - 6
32
+ - 0
33
+ version: 0.6.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 9
45
+ segments:
46
+ - 0
47
+ - 9
48
+ - 25
49
+ version: 0.9.25
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 49
61
+ segments:
62
+ - 0
63
+ - 8
64
+ - 7
65
+ version: 0.8.7
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 7
77
+ segments:
78
+ - 1
79
+ - 4
80
+ - 0
81
+ version: 1.4.0
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: rspec
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 27
93
+ segments:
94
+ - 1
95
+ - 3
96
+ - 0
97
+ version: 1.3.0
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: *id005
101
+ description: Useful Ruby FFI bindings for libc.
102
+ email: postmodern.mod3@gmail.com
103
+ executables: []
104
+
105
+ extensions: []
106
+
107
+ extra_rdoc_files:
108
+ - ChangeLog.md
109
+ - LICENSE.txt
110
+ - README.md
111
+ files:
112
+ - .gitignore
113
+ - .specopts
114
+ - .yardopts
115
+ - ChangeLog.md
116
+ - Gemfile
117
+ - LICENSE.txt
118
+ - README.md
119
+ - Rakefile
120
+ - VERSION
121
+ - ffi-libc.gemspec
122
+ - lib/ffi/libc.rb
123
+ - lib/ffi/libc/libc.rb
124
+ - lib/ffi/libc/timeval.rb
125
+ - lib/ffi/libc/timezone.rb
126
+ - lib/ffi/libc/types.rb
127
+ has_rdoc: yard
128
+ homepage: http://github.com/postmodern/ffi-libc
129
+ licenses:
130
+ - MIT
131
+ post_install_message:
132
+ rdoc_options: []
133
+
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 3
142
+ segments:
143
+ - 0
144
+ version: "0"
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ hash: 3
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ requirements: []
155
+
156
+ rubyforge_project:
157
+ rubygems_version: 1.3.7
158
+ signing_key:
159
+ specification_version: 3
160
+ summary: Useful FFI bindings for libc
161
+ test_files: []
162
+