mdoc

Generates a fully-formed HTML document from Markdown using cmark.
git clone git://src.gearsix.net/mdoc
Log | Files | Refs | Atom | README

commit 3bbe3d0a7a9da59163b70c63636ce1f4e4c6423c
parent 800c45422ea9c0ea8b9287c98f86b075c1487adb
Author: gearsix <gearsix@tuta.io>
Date:   Sat,  6 Nov 2021 15:25:44 +0000

added cleanexit() for SIGINT

Diffstat:
Mmdoc.c | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/mdoc.c b/mdoc.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include <cmark.h> @@ -50,6 +51,11 @@ size_t cmark(const size_t bufsiz, FILE *in, FILE *out) return n; } +void cleanexit() { + printfoot(); + exit(SIGINT); +} + int main(int argc, char *argv[]) { if (argc > 1 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--usage") == 0)) { @@ -73,7 +79,10 @@ int main(int argc, char *argv[]) } } + void (*sig)(int) = 0; + sig = signal(SIGINT, cleanexit); + printhead(title, author); - while (cmark(BUFSIZ, stdin, stdout) == BUFSIZ); + while (!sig && cmark(BUFSIZ, stdin, stdout) == BUFSIZ); printfoot(); }