{"id":19045456,"url":"https://github.com/keharriso/ocelot","last_synced_at":"2025-06-11T20:34:49.410Z","repository":{"id":68510515,"uuid":"496038095","full_name":"keharriso/ocelot","owner":"keharriso","description":"Parse C headers to identify function prototypes, type declarations, and global variables","archived":false,"fork":false,"pushed_at":"2023-07-08T15:25:41.000Z","size":32,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T17:46:06.628Z","etag":null,"topics":["c","header-parser"],"latest_commit_sha":null,"homepage":"","language":"C","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/keharriso.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-25T01:11:03.000Z","updated_at":"2024-10-15T16:30:47.000Z","dependencies_parsed_at":"2024-11-08T22:50:19.242Z","dependency_job_id":null,"html_url":"https://github.com/keharriso/ocelot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keharriso/ocelot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keharriso%2Focelot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keharriso%2Focelot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keharriso%2Focelot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keharriso%2Focelot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keharriso","download_url":"https://codeload.github.com/keharriso/ocelot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keharriso%2Focelot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259335037,"owners_count":22842481,"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","header-parser"],"created_at":"2024-11-08T22:50:15.771Z","updated_at":"2025-06-11T20:34:49.370Z","avatar_url":"https://github.com/keharriso.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# ocelot\n\nParse C headers to identify function prototypes, type declarations, and global variables.\n\n## Components and Features\n\n`ocelot` provides a very simple interface for breaking down C files into their most primitive constituent parts. Given a source file and a list of include directories, the library will produce an exhaustive list of all top-level functions, types, and variables.\n\n`ocelot` also optionally supports parsing and serializing of generated symbol tables via [JSON](https://www.json.org/). This allows for easy interoperability with other tools and languages.\n\n`ocelot-cli` is a simple command-line tool that uses `ocelot` to output JSON symbol tables for target C files.\n\n## Why?\n\nWouldn't it be nice to be able to just \"include\" C header files in other languages and have the FFI layer handle all the binding glue for you? FFI implementations can leverage `ocelot` to support this. `ocelot` will provide complete type information, so you don't need to worry about implementing this on your own. `ocelot` can also help out if your compiler is targeting C, in which case you'll be interested in finding the names and types of global variables, structs, and union members.\n\n## What is it not?\n\n`ocelot` is not a fully-fledged AST parser. It does not provide access to macros, function bodies, or even function parameter names. Instead, it gives you all of the type information you need to call a C function from another language.\n\n## API\n\n`ocelot` is simple to use.\n\n```c\n#include \"ocelot.h\"\n\nint main(void)\n{\n\tocelot_symbols *symbols = ocelot_parse(\"header.h\", 0);\n\tocelot_symbol **all_symbols = ocelot_symbols_get_all(symbols);\n\tocelot_symbol **itr;\n\tfor (itr = all_symbols; *itr; itr++)\n\t{\n\t\tprintf(\"symbol: `%s`\\n\", (*itr)-\u003ename);\n\t}\n\tfree(all_symbols);\n\tocelot_symbols_delete(symbols);\n\treturn 0;\n}\n```\n\nSee [ocelot.h](src/ocelot.h) for the complete API.\n\n## CLI\n\n```bash\n$ ocelot header.h \u003e header.json\n```\n\n## JSON Examples\n\n`ocelot` comes with an example JSON symbol table produced from `ocelot.h` itself. Find the example [here](examples/ocelot.h.json).\n\n## Building\n\nFirst you need to fetch the code:\n\n```bash\n$ git clone --recursive https://github.com/keharriso/ocelot.git\n```\n\n`ocelot` depends on [LibClang](https://clang.llvm.org/doxygen/group__CINDEX.html). The standard way to build `ocelot` is to use [CMake](https://cmake.org/).\n\n```bash\n$ mkdir build\n$ cd build\n$ cmake ..\n$ make\n```\n\nJSON support is enabled by default when building with CMake. To disable it, add -DOCELOT_ENABLE_JSON=OFF to the cmake command.\n\nWhen compiling without CMake, you need to define OCELOT_ENABLE_JSON to enable JSON support.\n\n## License\n\nCopyright (c) 2022 Kevin Harrison, released under the MIT License (see LICENSE for details).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeharriso%2Focelot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeharriso%2Focelot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeharriso%2Focelot/lists"}