Module: FFI::LibC
- Extended by:
- Library
- Defined in:
- lib/ffi/libc/af.rb,
lib/ffi/libc/libc.rb,
lib/ffi/libc/types.rb,
lib/ffi/libc/rusage.rb,
lib/ffi/libc/ifaddrs.rb,
lib/ffi/libc/in_addr.rb,
lib/ffi/libc/timeval.rb,
lib/ffi/libc/in6_addr.rb,
lib/ffi/libc/sockaddr.rb,
lib/ffi/libc/timezone.rb,
lib/ffi/libc/sockaddr_dl.rb,
lib/ffi/libc/sockaddr_in.rb,
lib/ffi/libc/sockaddr_in6.rb,
lib/ffi/libc/ifaddrs_union.rb,
lib/ffi/libc/sockaddr_family.rb
Defined Under Namespace
Modules: AF Classes: Ifaddrs, IfaddrsUnion, In6Addr, InAddr, RUsage, Sockaddr, SockaddrDL, SockaddrFamily, SockaddrIn, SockaddrIn6, Timeval, Timezone
Constant Summary collapse
- NULL =
The NULL constant
nil
- NI_MAXHOST =
1024
- NI_MAXSERV =
32
- NI_NUMERICHOST =
Don't try to look up hostname.
1
- NI_NUMERICSERV =
Don't convert port number to name.
2
- NI_NOFQDN =
Only return nodename portion.
4
- NI_NAMEREQD =
Don't return numeric addresses.
8
- NI_DGRAM =
Look up UDP service rather than TCP.
16
- RUSAGE_SELF =
bits/resource.h (Linux) / sys/resource.h (Darwin)
0
- RUSAGE_CHILDREN =
-1
- RUSAGE_THREAD =
Linux/glibc only
1
Class Method Summary collapse
-
.each_ifaddr {|ifaddr| ... } ⇒ Enumerator
Enumerates over the Interface Addresses.
- .raise_error(error = self.errno) ⇒ Object
-
.rusage(who = RUSAGE_SELF) ⇒ RUsage
Gets the RUsage for the user.
Class Method Details
.each_ifaddr {|ifaddr| ... } ⇒ Enumerator
Enumerates over the Interface Addresses.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/ffi/libc/libc.rb', line 165 def self.each_ifaddr return enum_for(__method__) unless block_given? ptr = MemoryPointer.new(:pointer) if getifaddrs(ptr) == -1 raise_error end if (ifaddrs = ptr.get_pointer(0)).null? return end ifaddr = Ifaddrs.new(ifaddrs) while ifaddr yield ifaddr ifaddr = ifaddr.next end freeifaddrs(ifaddrs) end |
.raise_error(error = self.errno) ⇒ Object
26 27 28 |
# File 'lib/ffi/libc/libc.rb', line 26 def self.raise_error(error=self.errno) raise(strerror(error)) end |