{"id":42357694,"url":"https://github.com/rstemmer/libprinthex","last_synced_at":"2026-01-27T16:36:46.565Z","repository":{"id":170258003,"uuid":"97389679","full_name":"rstemmer/libprinthex","owner":"rstemmer","description":"🔧 A library to print a buffer as typical hex-view with highlighted regions on the console screen.","archived":false,"fork":false,"pushed_at":"2024-12-01T15:16:58.000Z","size":74,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-01T15:35:59.653Z","etag":null,"topics":["ansi-colors","ansi-escape-sequences","console","debugging","hex-viewer","library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rstemmer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2017-07-16T14:42:34.000Z","updated_at":"2024-12-01T15:15:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b7dd94b-418b-4b11-8eea-89880e2f60f6","html_url":"https://github.com/rstemmer/libprinthex","commit_stats":null,"previous_names":["rstemmer/libprinthex"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rstemmer/libprinthex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstemmer%2Flibprinthex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstemmer%2Flibprinthex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstemmer%2Flibprinthex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstemmer%2Flibprinthex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rstemmer","download_url":"https://codeload.github.com/rstemmer/libprinthex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rstemmer%2Flibprinthex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28816563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ansi-colors","ansi-escape-sequences","console","debugging","hex-viewer","library"],"created_at":"2026-01-27T16:36:46.492Z","updated_at":"2026-01-27T16:36:46.550Z","avatar_url":"https://github.com/rstemmer.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libPrintHex\n\nlibprinthex provides a function to print a hex dump with colored sections.\n\n![Example output](screenshot.jpg?raw=true)\n\n**Project State:** Alive and maintained\n\nTested on Linux with Konsole and MacOS with Terminal\n\n## Installation\n\nYou should check the `install.sh` script before executing.\nThe default installation path is _/usr/local/{lib,include}_\n\n```bash\n./build.sh\nsudo ./install.sh\n```\n\n## Usage\n\n```c\nint printhex(void* buffer, int size, int bytesperline, ... );\n```\n\nThis function prints the bytes of a buffer as a typical hex-view to the screen.\n\n##### void* buffer\n\n_buffer_ points to the bytes that will be printed by `printhex`.\nThis can be anything as long as there is read access to _size_ bytes started at the address\n_buffer_ points to. \n\n##### int size\n\nThe _size_ is the number of bytes that will be printed in total.\nIt should be less or equal to the buffer _buffer_ points to.\n\n##### int bytesperline\n\nThis parameter determines how many bytes will be printed in each line.\nA good argument would be `16`.\n\n##### ...\n\nThe optional arguments are in alternating _offset_ and _color_.\nThere can be as many pairs of _offset_ and _color_ as there are bytes in the _buffer_.\nWhen the internal index to the values inside the buffer reached _offset_, the new text _color_ gets read from the argument list.\nFurthermore the next _offset_ will be read. So the algorithm expects an infinite list of offsets and colors.\nThe last value has to be an offset that will never be reached (a good value is `-1`).\n\nThe _offset_ must be an integer between `0` and `bytesperline - 1`.\nFurthermore it must be greater than the previous offset given in the list or arguments.\nIt determines the offset from which a new color will be used to print the values of the _buffer_.\n\nThe _color_ is the ANSI escape sequence for the color that will be used to print the values of the _buffer_ after the _offset_ related to that color is reached.\n\n##### return value\n\nThis function always returns 0\n\n## Example\n\n```c\n// Display Hello World, with World in green letters\nchar *helloworld = \"Hello World\";\nprinthex(helloworld, strlen(helloworld), 16, \n        6, \"\\e[1;32m\",   // Green World\n        -1);             // (end of offset/color list)\nprintf(\"\\n\");\n```\n\nYou will find a real example in the _test.c_ file.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frstemmer%2Flibprinthex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frstemmer%2Flibprinthex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frstemmer%2Flibprinthex/lists"}