{"id":16164276,"url":"https://github.com/troglobit/pev","last_synced_at":"2025-03-18T22:31:29.382Z","repository":{"id":57787266,"uuid":"312820542","full_name":"troglobit/pev","owner":"troglobit","description":"Portable Event Library","archived":false,"fork":false,"pushed_at":"2024-10-20T17:33:49.000Z","size":62,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-28T12:45:50.906Z","etag":null,"topics":["bsd","event-driven","event-library","linux","portable","portable-library","public-domain","signals","socket-io","sockets","timers","unix"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/troglobit.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"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":"2020-11-14T13:16:26.000Z","updated_at":"2024-12-02T17:48:15.000Z","dependencies_parsed_at":"2024-10-27T19:17:49.862Z","dependency_job_id":"1493ff8c-7162-4740-aa69-0935c5719426","html_url":"https://github.com/troglobit/pev","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fpev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fpev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fpev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/troglobit%2Fpev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/troglobit","download_url":"https://codeload.github.com/troglobit/pev/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955051,"owners_count":20374368,"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":["bsd","event-driven","event-library","linux","portable","portable-library","public-domain","signals","socket-io","sockets","timers","unix"],"created_at":"2024-10-10T02:46:02.503Z","updated_at":"2025-03-18T22:31:29.169Z","avatar_url":"https://github.com/troglobit.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Portable Event Library (PEV)\n============================\n[![License Badge][]][License] [![GitHub Status][]][GitHub] [![Coverity Status][]][Coverity Scan]\n\nThis is a small event library in C based around `select()` available\nfree for use in the [*public domain*](UNLICENSE).\n\n\nUpgrade Warnings\n----------------\n\nHeads-up, breaking changes in these versions!\n\n  * v1.3 changes timer resolution from 1 second to 1 microsecond\n  * v1.5 changes timer API to add support for one-shot timers\n  * v2.0 timer callbacks now get `id` as first argument, not timeout\n\nSee [ChangeLog](ChangeLog.md) for details.\n\n\nThe Code\n--------\n\nThe event loop consists of two files: `pev.c` and `pev.h`.  You can use\nit as a library or just include the components into your own project.\n\nSee the header file for the API description.  If you find bugs or have\nfixes to share, please report them using [GitHub issues][] or, preferably,\n[pull requests][].\n\n\nExample\n-------\n\n```C\n#include \u003cstdio.h\u003e\n#include \u003csignal.h\u003e\n#include \"pev.h\"\n\n#define TIMEOUT 500000      /* 0.5 sec */\n\nint id;\n\nstatic void cb(int timeout, void *arg)\n{\n        printf(\"Hej %d\\n\", timeout);\n        pev_timer_set(id, timeout + TIMEOUT);\n}\n\nstatic void br(int signo, void *arg)\n{\n        pev_exit(10);\n}\n\nint main(void)\n{\n        pev_init();\n        pev_sig_add(SIGINT, br, NULL);\n        id = pev_timer_add(TIMEOUT, 0, cb, NULL);\n\n        return pev_run();\n}\n```\n\nGives the following output:\n\n```sh\n$ gcc -I. -o example example.c pev.c\n$ ./example\nHej 500000\nHej 1000000\nHej 1500000\nHej 2000000\nHej 2500000\n^C\n```\n\n\nImplementation Notes\n--------------------\n\n**Note:** The timer implementation uses `setitimer()` for maximum\n\tportability.  Depending on the system, this can potentially cause\n\tproblems if your application also use `sleep()`, `usleep()`, or\n\t`alarm()`, which may all use the same back end implantation in your\n\toperating system.  Please check the documentation for your OS for\n\tmore information on the subject.\n\n\nBuilding and Testing\n--------------------\n\nFor those that don't just take the sources and integrate into their own\nproject.  You may have to set `CC`, to install you must set `prefix`.\nExample:\n\n    make clean\n    make CC=clang\n    make install prefix=/usr/local\n    ...\n    make uninstall prefix=/usr/local\n\n\nHistory and Background\n----------------------\n\nThe design evolved over time in the [SMCRoute][] project, where I wanted\nto keep the tool small and with as few (no) external dependencies as\npossible.\n\nIt started out as a refactor of the socket polling functionality, and\nreally came into its own in 2017 when I found Mr Rich Felker's mention\nof the classic [timer-to-pipe pattern][1] on Stack Overflow.\n\nIn the years passed I've noticed many times the need for a really small\nand, most importantly, *portable* event loop.  So here's the code I\nwrote for SMCRoute, cleaned up and now fully free in the public domain.\n\nTake care!  \n /Joachim :-)\n\n[1]:               https://stackoverflow.com/questions/2328127/select-able-timers/6800676#6800676\n[SMCRoute]:        https://github.com/troglobit/SMCRoute\n[GitHub issues]:   https://github.com/troglobit/pev/issues\n[pull requests]:   https://github.com/troglobit/pev/pulls\n[License]:         https://unlicense.org/\n[License Badge]:   https://img.shields.io/badge/License-Unlicense-blue.svg\n[GitHub]:          https://github.com/troglobit/pev/actions/workflows/build.yml/\n[GitHub Status]:   https://github.com/troglobit/pev/actions/workflows/build.yml/badge.svg\n[Coverity Scan]:   https://scan.coverity.com/projects/30840\n[Coverity Status]: https://scan.coverity.com/projects/30840/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroglobit%2Fpev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftroglobit%2Fpev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftroglobit%2Fpev/lists"}