Last active
December 18, 2021 19:03
-
-
Save NSAntoine/a79f01e71cb62044fac504f2ea68c3df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// Returns a ioctl number from a specified group and number | |
func getIoctlNumber(group: Character, number n:UInt) -> UInt { | |
let void = UInt(IOC_VOID) | |
let g: UInt = UInt(group.asciiValue!) << 8 | |
return void | g | n | |
} | |
// Example: | |
// DKIOCEJECT (atleast for Darwin platforms) is the 21th of group d | |
// let DKIOCEJECT = getIoctlNumber(group: "d", number: 21) | |
// print("DKIOEject Ioctl Code: \(DKIOCEJECT)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment