From a91a24e2be995c10a0e403b03d0cd3a1e36cd527 Mon Sep 17 00:00:00 2001 From: John R Patek Sr <31934875+johnpatek@users.noreply.github.com> Date: Sun, 5 Jan 2025 11:13:54 -0600 Subject: [PATCH] Updated Doxygen Config (#18) * updated doxygen config --- docs/CMakeLists.txt | 2 + docs/Doxyfile.in | 5 +- docs/mainpage.md | 109 -------------------------------------------- 3 files changed, 5 insertions(+), 111 deletions(-) delete mode 100644 docs/mainpage.md diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 65d2cfd..2dac818 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -6,6 +6,8 @@ set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) configure_file(${doxyfile_in} ${doxyfile} @ONLY) +message(${PROJECT_SOURCE_DIR}) + add_custom_target(docs COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 75192a0..d9eb2ea 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -12,11 +12,12 @@ QUIET = NO PROJECT_NAME = "SigFn" #PROJECT_NUMBER = @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@ INPUT = @PROJECT_SOURCE_DIR@/docs \ - @PROJECT_SOURCE_DIR@/include + @PROJECT_SOURCE_DIR@/include \ + @PROJECT_SOURCE_DIR@ FILE_PATTERNS = *.hpp \ *h \ *.md EXTRACT_ALL = YES OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/docs -USE_MDFILE_AS_MAINPAGE = mainpage.md \ No newline at end of file +USE_MDFILE_AS_MAINPAGE = README.md \ No newline at end of file diff --git a/docs/mainpage.md b/docs/mainpage.md deleted file mode 100644 index 2517b15..0000000 --- a/docs/mainpage.md +++ /dev/null @@ -1,109 +0,0 @@ -# SigFn - -![status](https://github.com/maxtek6/sigfn/actions/workflows/pipeline.yml/badge.svg) -[![codecov](https://codecov.io/gh/maxtek6/sigfn/branch/master/graph/badge.svg)](https://codecov.io/gh/maxtek6/sigfn) - -Bind callback functions to OS signals in C and C++. - -## Usage - -SigFn usage is similar to the `os/signal` package from Golang. - -### C - -Basic SigFn usage in C: - -```c -#include -#include -// to implement sleep_for() -#ifdef _WIN32 -#include -#else -#include -#endif - -// signal handler -static void handle_signal(int signum, void *userdata); - -// helper function to abstract platform dependent sleep functions -static void sleep_for(int ms); - -int main() -{ - // used to store signum - int flag; - - // initialize to what should be an impossible value for SIGINT - flag = -1; - - // set callback for SIGINT - sigfn_handle(SIGINT, handle_signal, &flag); - - // notify user that the program is "paused" - puts("Paused. Press Ctrl+C to exit."); - - // sleep loop until we receive the signal - while (flag < 0) - { - // this should stop the CPU from being overworked - sleep_for(100); - } - - // notify user that flag was set and exit cleanly - printf("\nReceived signal: %d\n", flag); - - return 0; -} - -void handle_signal(int signum, void *userdata) -{ - // set int that was passed by address - *(int*)userdata = signum; -} - -void sleep_for(int ms) -{ -#ifdef _WIN32 - Sleep(ms); -#else - const struct timespec duration = { - .tv_sec = ms / 1000, - .tv_nsec = (ms % 1000) * 1000000, - }; - nanosleep(&duration, NULL); -#endif -} -``` - -### C++ - -Basic SigFn usage in C++: - -```cpp -#include -#include -#include - -int main(int argc, const char **argv) -{ - bool loop; - // set callback for SIGINT - sigfn::handle(SIGINT, [&](int signum) { - std::cout << std::endl << "Received signal: " << signum << std::endl; - loop = false; - }); - - // notify user that the program is "paused" - std::cout << "Paused. Press Ctrl+C to exit." << std::endl; - - // sleep loop until we receive the signal - loop = true; - while(loop) - { - // sleep for 100ms - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } - return 0; -} -``` \ No newline at end of file