{"id":13713972,"url":"https://github.com/thales-e-security/header2go","last_synced_at":"2026-02-10T08:04:06.351Z","repository":{"id":57592522,"uuid":"154813286","full_name":"thales-e-security/header2go","owner":"thales-e-security","description":"Convert C header files into skeleton Go implementations","archived":false,"fork":false,"pushed_at":"2018-11-08T12:04:10.000Z","size":165,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-03T23:29:25.887Z","etag":null,"topics":["c","cgo","generator","go","header-files"],"latest_commit_sha":null,"homepage":"","language":"Go","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/thales-e-security.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-26T09:50:27.000Z","updated_at":"2024-03-14T16:34:13.000Z","dependencies_parsed_at":"2022-09-14T09:12:32.357Z","dependency_job_id":null,"html_url":"https://github.com/thales-e-security/header2go","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thales-e-security%2Fheader2go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thales-e-security%2Fheader2go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thales-e-security%2Fheader2go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thales-e-security%2Fheader2go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thales-e-security","download_url":"https://codeload.github.com/thales-e-security/header2go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224551110,"owners_count":17330071,"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","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":["c","cgo","generator","go","header-files"],"created_at":"2024-08-02T23:01:49.025Z","updated_at":"2026-02-10T08:04:06.324Z","avatar_url":"https://github.com/thales-e-security.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# header2go\n\n[![Build Status](https://travis-ci.com/thales-e-security/header2go.svg?branch=master)](https://travis-ci.com/thales-e-security/header2go)\n[![Coverage Status](https://coveralls.io/repos/github/thales-e-security/header2go/badge.svg?branch=master)](https://coveralls.io/github/thales-e-security/header2go?branch=master)\n[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://raw.githubusercontent.com/thales-e-security/header2go/master/LICENSE)\n\n\nheader2go generates skeleton Go implementations of C header files, which can be compiled with cgo to produce a shared\nlibrary.\n\n## Installation\n\nPlease download a release from the releases page. We will release early and often, so building from source should\nbe unneeded.\n\nIf you want to build from source, you will first need to install dep. Then execute:\n\n```\ngo get -d github.com/thales-e-security/header2go\ncd $GOPATH/src/github.com/thales-e-security/header2go\ndep ensure --vendor-only\ngo install .\n```\n\n## Usage\n\nThe command-line interface is very simple, just execute:\n\n```\nheader2go \u003cheader-file\u003e \u003coutput-dir\u003e [\u003cconfig-file\u003e]\n```\n\nThe tool processes `\u003cheader-file\u003e` and any included headers, before outputting the boilerplate code into `\u003coutput-dir\u003e`.\nThe tool will happily overwrite existing files in `\u003coutput-dir\u003e`, so be cautious.\n\nVoid pointers are handled by mappings in a configuration file. See [the wiki](https://github.com/thales-e-security/header2go/wiki/Void-Pointers).\n\nIf the processing completed successfully, it should be possible to compile the skeleton implementation using:\n\n```\ncd \u003coutput-dir\u003e\ngo build -o library.so -buildmode=c-shared . \n```\n\nwhich will produce a `library.so` file that can be linked into C programs.\n\n## Documentation\n\nPlease see the [wiki](https://github.com/thales-e-security/header2go/wiki).\n\n## Background\n\nThis project makes it easier to implement legacy APIs, described by C header files, in Go. The\noriginal motivation was PKCS\u0026nbsp;#11, a popular crypto API described by C header files and linked into dependent \napplications. We were interested in implementing this API using Go, but found the process of producing\nthe necessary CGo boiler-plate code rather tedious and error-prone.\n\nheader2go isn't yet capable of processing the whole PKCS\u0026nbsp;#11 header set. 90% of the contents are successfully parsed at\npresent and the tool takes care to output as much useful boilerplate as possible, even in the face of errors.\n\n## Contributing\n\nContributions are very welcome. The tool is slowly growing in capability and there are plenty of tasks still to be done.\nBefore submitting a pull request, please ensure you have created a new test case (in `translate/testdata`) that tests\nthe generated code you expect to produce. The code in that directory should compile using cgo. Bonus points are awarded\nif you include some C code that proves your generated code works, see  \n`translate/testdata/08_pointers_to_structs_with_basic_types` for an example of that.\n\n### TODO list (not exhaustive)\n\n- [x] Command line interface\n- [x] Basic function return types (no structs)\n- [x] Pointer types as input parameters (copying into Go memory and back)\n- [x] Fixed array types (e.g. char[16])\n- [x] (Testing with) additional header files, i.e. #include statements\n- [x] Void pointer parameter types (should map to unsafe.Pointer)\n- [ ] Pointers to structs that contain pointers. (Makes the `convertFromXXX` functions more complicated).\n- [ ] Function pointers (e.g. `typedef CK_RV(*CK_C_Finalize) (CK_VOID_PTR pReserved);`, which is a type called `CK_C_Finalize` that is a function returning `CK_RV` and taking an arguments of type `CK_VOID_PTR`.)\n- [ ] Arbitrary return types\n- [ ] Submit a PR to the github.com/elliotchance/c2go to refactor their code, ensuring we don't need to copy bits across to this project.\n- [ ] Generate a suitable config file, based on scanning for void pointers.\n\n## Acknowledgements\n\nThis project uses the Clang AST parsing capabilities from https://github.com/elliotchance/c2go. Mostly this is achieved\nby importing packages, however a small amount of code has been copied into `translate/astparse/parse.go`. The license\nand copyright information is noted in that file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthales-e-security%2Fheader2go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthales-e-security%2Fheader2go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthales-e-security%2Fheader2go/lists"}