{"id":18497805,"url":"https://github.com/containers/libocispec","last_synced_at":"2025-04-06T14:12:59.735Z","repository":{"id":39040882,"uuid":"85476596","full_name":"containers/libocispec","owner":"containers","description":"a C library for accessing OCI runtime and image spec files","archived":false,"fork":false,"pushed_at":"2025-01-27T07:17:07.000Z","size":526,"stargazers_count":55,"open_issues_count":2,"forks_count":31,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-30T13:09:11.765Z","etag":null,"topics":["c","containers","oci","parser","rust"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/containers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-19T13:06:29.000Z","updated_at":"2025-01-25T13:08:19.000Z","dependencies_parsed_at":"2024-03-02T04:32:07.321Z","dependency_job_id":"95ed3cf5-5116-493d-8052-20417d064091","html_url":"https://github.com/containers/libocispec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containers%2Flibocispec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containers%2Flibocispec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containers%2Flibocispec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/containers%2Flibocispec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/containers","download_url":"https://codeload.github.com/containers/libocispec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492566,"owners_count":20947545,"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","containers","oci","parser","rust"],"created_at":"2024-11-06T13:35:57.795Z","updated_at":"2025-04-06T14:12:59.717Z","avatar_url":"https://github.com/containers.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"libocispec\n==========\n\n[![Build Status](https://travis-ci.org/containers/libocispec.svg?branch=master)](https://travis-ci.org/containers/libocispec)\n\nA library for easily parsing\nof [OCI runtime](https://github.com/opencontainers/runtime-spec)\nand [OCI image](https://github.com/opencontainers/image-spec) files\nfrom C, and generate json string from corresponding struct.\n\nThe parser is generated directly from the JSON schema in the source repository.\n\n## Installation\nExpects [yajl](https://github.com/containers/yajl) to be installed and linkable.\n```sh\n$ ./autogen.sh\n$ ./configure\n$ make\n$ sudo make install\n```\n\nParsing an OCI configuration file is easy as:\n\n```c\n    #include \u003cconfig.h\u003e\n    #include \u003cruntime_spec_schema_config_schema.h\u003e\n\n    runtime_spec_schema_config_schema *container = runtime_spec_schema_config_schema_parse_file (\"config.json\", NULL, \u0026err);\n\n    if (container == NULL)\n      exit (EXIT_FAILURE);\n\n    /* Print the container hostname.  */\n    if (container-\u003ehostname)\n        printf (\"The specified hostname is %s\\n\", container-\u003ehostname);\n\n    for (size_t i; i \u003c container-\u003emounts_len; i++)\n        printf (\"Mounting to %s\\n\", container-\u003emounts[i]-\u003edestination);\n\n    printf (\"Running as user ID and GID %d %d\\n\", container-\u003eprocess-\u003euser-\u003euid, container-\u003eprocess-\u003euser-\u003egid);\n\n```\n\nGenerating an OCI configuration json string is also easy as:\n\n```c\n    #include \u003cconfig.h\u003e\n    #include \u003cruntime_spec_schema_config_schema.h\u003e\n\n    runtime_spec_schema_config_schema container;\n    char *json_buf = NULL;\n\n    memset (\u0026container, 0, sizeof (runtime_spec_schema_config_schema));\n\n    container.oci_version = \"2\";\n    container.hostname = \"ubuntu\";\n    /* Add other configuration. */\n    /* ... ... */\n\n    json_buf = runtime_spec_schema_config_schema_generate_json (\u0026container, NULL, \u0026err);\n    if (json_buf == NULL)\n      exit (EXIT_FAILURE);\n\n    printf (\"The generated json string is:\\n%s\\n\", json_buf);\n\n```\n## Rust Bindings\nlibocispec supports rust bindings as well. You can use it directly by adding it as dependency to `Cargo.toml` or generate fresh types using `make generate-rust`\n```toml\n[dependencies]\nlibocispec = { git = \"https://github.com/containers/libocispec\" }\n```\nfor Cargo version older than `0.51.0` specify branch explicitly\n```toml\n[dependencies]\nlibocispec = { git = \"https://github.com/containers/libocispec\", branch = \"main\" }\n```\nExample usage\n```rust\nextern crate libocispec;\nuse libocispec::runtime;\nuse libocispec::image;\n\nfn main() {\n    let runtime_spec = match runtime::Spec::load(\"path/to/spec\") {\n        Ok(spec) =\u003e spec,\n        Err(e) =\u003e panic!(\"{}\", e),\n    }\n    let image_spec = match image::ImageConfig::load(\"path/to/spec\") {\n        Ok(spec) =\u003e spec,\n        Err(e) =\u003e panic!(\"{}\", e),\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainers%2Flibocispec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontainers%2Flibocispec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontainers%2Flibocispec/lists"}