{"id":23508760,"url":"https://github.com/lovasko/libtabl","last_synced_at":"2025-10-26T14:05:15.097Z","repository":{"id":33915481,"uuid":"37634255","full_name":"lovasko/libtabl","owner":"lovasko","description":"ANSI Pedantic C89 Table Layout for Command Line","archived":false,"fork":false,"pushed_at":"2016-03-12T06:01:43.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T19:48:24.846Z","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":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovasko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-18T03:05:35.000Z","updated_at":"2016-03-12T06:01:46.000Z","dependencies_parsed_at":"2022-09-13T19:21:14.554Z","dependency_job_id":null,"html_url":"https://github.com/lovasko/libtabl","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/lovasko%2Flibtabl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibtabl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibtabl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibtabl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovasko","download_url":"https://codeload.github.com/lovasko/libtabl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253970763,"owners_count":21992563,"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-12-25T11:32:02.159Z","updated_at":"2025-10-26T14:05:15.044Z","avatar_url":"https://github.com/lovasko.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libtabl\nTable layout library for command line.\n\n## Features\n * string and integer cell content \n * left and right cell content alignment\n * strong arity checks\n * very high-level code (no loops used!)\n\n## Example\nCreate a table of user names and their IDs from `/etc/passwd`.\n\n```C\n#include \u003cstdlib.h\u003e\n#include \u003cpwd.h\u003e\n#include \u003cm_list.h\u003e\n\nint\nmain(void)\n{\n  struct passwd* pwd;\n  struct tabl t;\n  struct m_list values;\n\n  tabl_init(\u0026t);\n  tabl_add_column(\u0026t, \"UID\", TABL_CONTENT_DECIMAL, TABL_ALIGN_RIGHT);\n  tabl_add_column(\u0026t, \"Name\", TABL_CONTENT_STRING, TABL_ALIGN_LEFT);\n\n  m_list_init(\u0026values);\n  while ((pwd = getpwent()) != NULL) {\n    m_list_clear(\u0026values);\n    m_list_append(\u0026values, M_LIST_COPY_DEEP, \u0026pwd-\u003epw_uid, sizeof(uid_t));\n    m_list_append(\u0026values, M_LIST_COPY_DEEP, pwd-\u003epw_name, strlen(pwd-\u003epw_name)+1);\n    tabl_add_row(\u0026t, \u0026values);\n  }\n  endpwent();\n\n  tabl_render(\u0026t);\n  return EXIT_SUCCESS;\n}\n```\n\nCompile \u0026 run:\n```\n$ clang -o passwd passwd.c -ltabl\n$ ./passwd\n  UID Name\n    0 root\n    8 news\n    9 man\n   22 sshd\n   25 smmsp\n   26 mailnull\n   68 pop\n   78 auditdistd\n   80 www\n  845 hast\n65534 nobody\n```\n\n## Documentation \nThe usage of `libtabl` is completely linear. The whole workflow has four steps:\ninitialisation, column creation, row insertion and rendering of the table. The\norder of tasks must be preserved.\n\n### Initialisation\nUse the `tabl_init(struct tabl* t)` function to initialise a already allocated\ntable.\n\n### Column creation\nEach column is specified by the `name` displayed in the header, the `content`\nof the data in the column and the `align`ment of the data. To append a new\ncolumn to the table, use the `tabl_add_column(struct tabl* t, const char* name,\nuint8_t content, uint8_t align)`. Appending a new column after already\nappending some rows will result in an runtime error.\n\n#### Content\nContent can be one of the following:\n * `TABL_CONTENT_STRING` which expect the data to be a `NULL`-terminated string\n * `TABL_CONTENT_DECIMAL` which expect a single `int` of data that will be printed in the decimal format\n\n#### Alignment\nAlignment can be one of the following:\n * `TABL_ALIGN_LEFT` align content to the left\n * `TABL_ALIGN_RIGHT` align content to the right \n\n### Row insertion\nEach row is represented as a separate `m_list`. As a security measure, the\nnumber of columns and number of elements in the row is compared, to ensure the\narity consistence. To append a row, use the `tabl_add_row(struct tabl* t,\nstruct m_list* row)` function.\n\n### Table rendering\nTo render the finished table onto the `stdout`, use the `tabl_render(struct\ntabl* t)` function.\n\n## Supported platforms\n * FreeBSD 10.0 with Clang 3.3\n\nIf a platform does not appear to be in the previous list, it does not mean that\n`libtabl` will not work in such environment. It only means that nobody tested\nit - you are encouraged to do so and report either success or failure.\n\n## Dependencies\n * [m_list](github.com/lovasko/m_list)\n\n## Build\n```\n$ ninja\n```\n\n## License\n2-clause BSD license. For more information please consult the\n[license](LICENSE.md) file. In the case that you need a different license, feel\nfree to contact me.\n\n## Author\nDaniel Lovasko (lovasko@freebsd.org)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Flibtabl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovasko%2Flibtabl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Flibtabl/lists"}