ffi-procps 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,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ffi-procps.gemspec
4
+ gemspec
5
+
6
+ gem 'pry-doc'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Andreas Loupasakis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # ffi-procps
2
+
3
+ FFI wrapper for procps library
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ffi-procps'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ffi-procps
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ffi-procps/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ffi-procps"
8
+ gem.version = Ffi::Procps::VERSION
9
+ gem.authors = ["Andreas Loupasakis"]
10
+ gem.email = ["andreas@aloop.org"]
11
+ gem.description = %q{FFI wrapper for procps library}
12
+ gem.summary = %q{FFI wrapper for procps library}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "ffi"#, [">= 1.0.9"]
21
+ gem.add_development_dependency "rspec"
22
+ gem.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,162 @@
1
+ require 'ffi'
2
+ require "ffi-procps/version"
3
+
4
+ module Procps
5
+ module LibProc
6
+ extend FFI::Library
7
+ ffi_lib("libproc")
8
+
9
+
10
+ ### devname.h
11
+
12
+ #
13
+ # extern int tty_to_dev(const char *__restrict const name);
14
+ #
15
+ attach_function :tty_to_dev, [:string], :int
16
+
17
+ # TODO
18
+ #
19
+ # extern unsigned dev_to_tty(char *__restrict ret, unsigned chop, dev_t dev_t_dev, int pid, unsigned int flags);
20
+
21
+
22
+ ### pwcache.h
23
+
24
+ #
25
+ # extern char *user_from_uid(uid_t uid);
26
+ #
27
+ attach_function :user_from_uid, [:uint], :string
28
+
29
+ # TODO
30
+ #
31
+ # extern char *group_from_gid(gid_t gid);
32
+ #
33
+
34
+
35
+ ### whattime.h
36
+
37
+ #
38
+ # extern void print_uptime(void);
39
+ #
40
+ attach_function :print_uptime, [], :void
41
+
42
+ #
43
+ # extern char *sprint_uptime(void);
44
+ #
45
+ attach_function :sprint_uptime, [], :string
46
+
47
+
48
+ ### sysinfo.h
49
+
50
+ #
51
+ # extern void meminfo(void);
52
+ #
53
+ attach_function :meminfo, [], :void
54
+
55
+ #
56
+ # extern void vminfo (void);
57
+ #
58
+ attach_function :vminfo, [], :void
59
+
60
+
61
+ class Proc_t < FFI::Struct
62
+ layout :tid, :int,
63
+ :ppid, :int,
64
+ :pcpu, :uint,
65
+ :state, :char,
66
+ :pad_1, :char,
67
+ :pad_2, :char,
68
+ :pad_3, :char,
69
+ :utime, :ulong_long,
70
+ :stime, :ulong_long,
71
+ :cutime, :ulong_long,
72
+ :cstime, :ulong_long,
73
+ :start_time, :ulong_long,
74
+ :signal, :long_long,
75
+ :blocked, :long_long,
76
+ :sigignore, :long_long,
77
+ :sigcatch, :long_long,
78
+ :_sigpnd, :long_long,
79
+ :start_code, :ulong_long,
80
+ :end_code, :ulong_long,
81
+ :start_stack, :ulong_long,
82
+ :kstk_esp, :ulong_long,
83
+ :kstk_eip, :ulong_long,
84
+ :wchan, :ulong_long,
85
+ :priority, :long,
86
+ :nice, :long,
87
+ :rss, :long,
88
+ :alarm, :long,
89
+ :size, :long,
90
+ :resident, :long,
91
+ :share, :long,
92
+ :trs, :long,
93
+ :lrs, :long,
94
+ :drs, :long,
95
+ :dt, :long,
96
+ :vm_size, :ulong,
97
+ :vm_lock, :ulong,
98
+ :vm_rss, :ulong,
99
+ :vm_data, :ulong,
100
+ :vm_stack, :ulong,
101
+ :vm_swap, :ulong,
102
+ :vm_exe, :ulong,
103
+ :vm_lib, :ulong,
104
+ :rtprio, :ulong,
105
+ :sched, :ulong,
106
+ :vsize, :ulong,
107
+ :rss_rlim, :ulong,
108
+ :flags, :ulong,
109
+ :min_flt, :ulong,
110
+ :maj_flt, :ulong,
111
+ :cmin_flt, :ulong,
112
+ :cmaj_flt, :ulong,
113
+
114
+ :environ, :pointer,
115
+ :cmdline, :pointer,
116
+ :cgroup, :pointer,
117
+ :supgid, :pointer,
118
+ :supgrp, :pointer,
119
+
120
+ :euser, [:char, 20],
121
+ :ruser, [:char, 20],
122
+ :suser, [:char, 20],
123
+ :fuser, [:char, 20],
124
+ :rgroup, [:char, 20],
125
+ :egroup, [:char, 20],
126
+ :sgroup, [:char, 20],
127
+ :fgroup, [:char, 20],
128
+ :cmd, [:char, 16],
129
+
130
+ :ring, :pointer,
131
+ :next, :pointer,
132
+
133
+ :pgrp, :int,
134
+ :session, :int,
135
+ :nlwp, :int,
136
+ :tgid, :int,
137
+ :tty, :int,
138
+ :euid, :int,
139
+ :egid, :int,
140
+ :ruid, :int,
141
+ :rgid, :int,
142
+ :suid, :int,
143
+ :sgid, :int,
144
+ :fuid, :int,
145
+ :fgid, :int,
146
+ :tpgid, :int,
147
+ :exit_signal, :int,
148
+ :processor, :int,
149
+
150
+ :oom_store, :int,
151
+ :oom_adj, :int
152
+ end
153
+
154
+ ### readproc.h
155
+
156
+ #
157
+ # extern proc_t** readproctab(int flags, ... /* same as openproc */ );
158
+ #
159
+ attach_function :readproctab, [:int, :varargs], :pointer
160
+
161
+ end
162
+ end
@@ -0,0 +1,5 @@
1
+ module Ffi
2
+ module Procps
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffi-procps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andreas Loupasakis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffi
16
+ requirement: &14441960 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *14441960
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &14441480 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *14441480
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &14441000 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *14441000
47
+ description: FFI wrapper for procps library
48
+ email:
49
+ - andreas@aloop.org
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - ffi-procps.gemspec
60
+ - lib/ffi-procps.rb
61
+ - lib/ffi-procps/version.rb
62
+ homepage: ''
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.11
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: FFI wrapper for procps library
86
+ test_files: []
87
+ has_rdoc: