{"id":13438279,"url":"https://github.com/rxi/microtar","last_synced_at":"2025-04-05T00:10:32.954Z","repository":{"id":46298455,"uuid":"69743837","full_name":"rxi/microtar","owner":"rxi","description":"A lightweight tar library written in ANSI C","archived":false,"fork":false,"pushed_at":"2024-05-14T08:45:27.000Z","size":7,"stargazers_count":461,"open_issues_count":22,"forks_count":103,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-28T23:09:21.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rxi.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":"2016-10-01T14:39:48.000Z","updated_at":"2025-03-27T21:57:51.000Z","dependencies_parsed_at":"2022-09-19T09:10:45.436Z","dependency_job_id":"d50cac93-4064-4b30-b3eb-b0448674ede0","html_url":"https://github.com/rxi/microtar","commit_stats":{"total_commits":7,"total_committers":2,"mean_commits":3.5,"dds":0.1428571428571429,"last_synced_commit":"27076e1b9290e9c7842bb7890a54fcf172406c84"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fmicrotar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fmicrotar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fmicrotar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fmicrotar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxi","download_url":"https://codeload.github.com/rxi/microtar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266565,"owners_count":20910836,"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":[],"created_at":"2024-07-31T03:01:04.234Z","updated_at":"2025-04-05T00:10:32.931Z","avatar_url":"https://github.com/rxi.png","language":"C","readme":"# microtar\nA lightweight tar library written in ANSI C\n\n\n## Basic Usage\nThe library consists of `microtar.c` and `microtar.h`. These two files can be\ndropped into an existing project and compiled along with it.\n\n\n#### Reading\n```c\nmtar_t tar;\nmtar_header_t h;\nchar *p;\n\n/* Open archive for reading */\nmtar_open(\u0026tar, \"test.tar\", \"r\");\n\n/* Print all file names and sizes */\nwhile ( (mtar_read_header(\u0026tar, \u0026h)) != MTAR_ENULLRECORD ) {\n  printf(\"%s (%d bytes)\\n\", h.name, h.size);\n  mtar_next(\u0026tar);\n}\n\n/* Load and print contents of file \"test.txt\" */\nmtar_find(\u0026tar, \"test.txt\", \u0026h);\np = calloc(1, h.size + 1);\nmtar_read_data(\u0026tar, p, h.size);\nprintf(\"%s\", p);\nfree(p);\n\n/* Close archive */\nmtar_close(\u0026tar);\n```\n\n#### Writing\n```c\nmtar_t tar;\nconst char *str1 = \"Hello world\";\nconst char *str2 = \"Goodbye world\";\n\n/* Open archive for writing */\nmtar_open(\u0026tar, \"test.tar\", \"w\");\n\n/* Write strings to files `test1.txt` and `test2.txt` */\nmtar_write_file_header(\u0026tar, \"test1.txt\", strlen(str1));\nmtar_write_data(\u0026tar, str1, strlen(str1));\nmtar_write_file_header(\u0026tar, \"test2.txt\", strlen(str2));\nmtar_write_data(\u0026tar, str2, strlen(str2));\n\n/* Finalize -- this needs to be the last thing done before closing */\nmtar_finalize(\u0026tar);\n\n/* Close archive */\nmtar_close(\u0026tar);\n```\n\n\n## Error handling\nAll functions which return an `int` will return `MTAR_ESUCCESS` if the operation\nis successful. If an error occurs an error value less-than-zero will be\nreturned; this value can be passed to the function `mtar_strerror()` to get its\ncorresponding error string.\n\n\n## Wrapping a stream\nIf you want to read or write from something other than a file, the `mtar_t`\nstruct can be manually initialized with your own callback functions and a\n`stream` pointer.\n\nAll callback functions are passed a pointer to the `mtar_t` struct as their\nfirst argument. They should return `MTAR_ESUCCESS` if the operation succeeds\nwithout an error, or an integer below zero if an error occurs.\n\nAfter the `stream` field has been set, all required callbacks have been set and\nall unused fields have been zeroset the `mtar_t` struct can be safely used with\nthe microtar functions. `mtar_open` *should not* be called if the `mtar_t`\nstruct was initialized manually.\n\n#### Reading\nThe following callbacks should be set for reading an archive from a stream:\n\nName    | Arguments                                | Description\n--------|------------------------------------------|---------------------------\n`read`  | `mtar_t *tar, void *data, unsigned size` | Read data from the stream\n`seek`  | `mtar_t *tar, unsigned pos`              | Set the position indicator\n`close` | `mtar_t *tar`                            | Close the stream\n\n#### Writing\nThe following callbacks should be set for writing an archive to a stream:\n\nName    | Arguments                                      | Description\n--------|------------------------------------------------|---------------------\n`write` | `mtar_t *tar, const void *data, unsigned size` | Write data to the stream\n\n\n## License\nThis library is free software; you can redistribute it and/or modify it under\nthe terms of the MIT license. See [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":["C","Maths"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxi%2Fmicrotar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxi%2Fmicrotar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxi%2Fmicrotar/lists"}