{"id":30758272,"url":"https://github.com/postmodern/ioctl.cr","last_synced_at":"2025-09-04T11:05:34.978Z","repository":{"id":310608844,"uuid":"1040303526","full_name":"postmodern/ioctl.cr","owner":"postmodern","description":"Crystal bindings for libc's ioctl(2)","archived":false,"fork":false,"pushed_at":"2025-08-19T05:36:57.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-30T16:35:18.010Z","etag":null,"topics":["crystal-lang","ioctl"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postmodern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"postmodern"}},"created_at":"2025-08-18T19:09:58.000Z","updated_at":"2025-08-19T05:37:01.000Z","dependencies_parsed_at":"2025-08-19T07:23:32.915Z","dependency_job_id":"d194d20d-11c7-4638-8da6-bd500d66f23b","html_url":"https://github.com/postmodern/ioctl.cr","commit_stats":null,"previous_names":["postmodern/ioctl.cr"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/postmodern/ioctl.cr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmodern%2Fioctl.cr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmodern%2Fioctl.cr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmodern%2Fioctl.cr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmodern%2Fioctl.cr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postmodern","download_url":"https://codeload.github.com/postmodern/ioctl.cr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmodern%2Fioctl.cr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273596972,"owners_count":25134262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal-lang","ioctl"],"created_at":"2025-09-04T11:02:16.728Z","updated_at":"2025-09-04T11:05:34.944Z","avatar_url":"https://github.com/postmodern.png","language":"Crystal","funding_links":["https://github.com/sponsors/postmodern"],"categories":[],"sub_categories":[],"readme":"# ioctl.cr\n\n* [Source](https://github.com/postmodern/ioctl.cr)\n* [Issues](https://github.com/postmodern/ioctl.cr/issues)\n* [Docs](https://postmodern.github.io/docs/ioctrl.cr/index.html)\n\nlibc's [ioctl] for [Crystal][crystal].\n\n## Features\n\n### Functions\n\n* Maps in the libc `ioctl` function.\n* Provides C equivalent macros for defining and working with ioctl numbers:\n\n  | C           | Crystal                       |\n  |-------------|-------------------------------|\n  | `_IOC`      | `ioctl_ioc(dir,type,nr,size)` |\n  | `_IO`       | `ioctl_io(type,nr)`           |\n  | `_IOR`      | `ioctl_ior(type,nr,size)`     |\n  | `_IOW`      | `ioctl_iow(type,nr,size)`     |\n  | `_IOWR`     | `ioctl_iowr(type,nr,size)`    |\n  | `_IOR_BAD`  | `ioctl_ior_bad(type,nr,size)` |\n  | `_IOW_BAD`  | `ioctl_iow_bad(type,nr,size)` |\n  | `_IOWR_BAD` | `ioctl_iowr_bad(type,nr,size)`|\n  | `_IOC_DIR`  | `ioctl_dir(nr)`               |\n  | `_IOC_TYPE` | `ioctl_type(nr)`              |\n  | `_IOC_NR`   | `ioctl_nr(nr)`                |\n  | `_IOC_SIZE` | `ioctl_size(nr)`              |\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     ioctl:\n       github: postmodern/ioctl.cr\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"ioctl\"\n\noutput = MyStruct.new\n\nbegin\n  IOCTL.ioctl(fd, IOCTL::..., pointerof(output))\nrescue error : IOCTL::Error\n  # ...\nend\n```\n\nReturning `-1` instead of raising an exception:\n\n```crystal\nif LibC.ioctl(fd, IOCTL::..., pointerof(output)) == -1\n  # ...\nend\n```\n\n### Examples\n\nGet the terminal window size:\n\n```crystal\nwinsize = LibC::Winsize.new\n\nbegin\n  IOCTL.ioctl(STDOUT.fd, IOCTL::TIOCGWINSZ, pointerof(winsize))\nrescue error : IOCTL::Error\n  STDERR.puts error.message\n  exit -1\nend\n\nputs \"Rows: #{winsize.ws_row}\"\nputs \"Cols: #{winsize.ws_col}\"\n```\n\n## TODO\n\n* macOS / BSD support\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/postmodern/ioctl/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Postmodern](https://github.com/postmodern) - creator and maintainer\n\n[ioctl]: http://man7.org/linux/man-pages/man2/ioctl.2.html\n[crystal]: https://crystal-lang.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmodern%2Fioctl.cr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostmodern%2Fioctl.cr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmodern%2Fioctl.cr/lists"}