From b2fada1dd19211d71e04557653d08e697134a6ce Mon Sep 17 00:00:00 2001 From: Erik K Date: Fri, 13 May 2022 17:24:26 +0000 Subject: initial commit --- skull.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 skull.c (limited to 'skull.c') diff --git a/skull.c b/skull.c new file mode 100644 index 0000000..5c44f20 --- /dev/null +++ b/skull.c @@ -0,0 +1,82 @@ +#include +#include +#include +#include + +#include "sm.h" +#include "util.h" + +extern char kcontentdir[]; +extern char kskullexport[]; + +static void skullexport(Document **, int); + +Plugin skull = {"skull", skullexport, NULL, 0}; + +static void +skullexport(Document **doc, int ndoc) +{ + char path[512], outpath[512]; + FILE *outf; + int i, j; + + char title[128], creat[64], mod[64]; + char *header[] = { "\ +\n\ +\n\ + ", title, "\n\ + \n\ + \n\ +\n\ +\n\ + \"PreviousPlan!\n\ + \n\ +" }; + + char *footer[] = { "\ +
\n\ +

Written: ", creat, ", Last modified: ", mod, "

\n\ + \"EMAIL\"/\n\ +

Webmaster email: erikk@previousplan.org \ +(PGP key)

\n\ +\n\ +\n\ +" }; + + for (i = 0; i < ndoc; i++) { + snprintf(path, sizeof(path), "%s/%s", kcontentdir, doc[i]->filename); + snprintf(outpath, sizeof(outpath), "%s/%s", kskullexport, doc[i]->filename); + + if ((outf = fopen(outpath, "w")) == NULL) { + fprintf(stderr, "%s: %s\n", outpath, strerror(errno)); + continue; + } + + my_strlcpy(title, doc[i]->title, sizeof(title)); + strftime(creat, sizeof(creat), "%a, %Y %b %d", gmtime(&doc[i]->creat)); + strftime(mod, sizeof(mod), "%a, %Y %b %d", gmtime(&doc[i]->mod)); + for (j = 0; j < LEN(header); j++) + xfputs(header[j], outf); + cat(path, outf); + for (j = 0; j < LEN(footer); j++) + xfputs(footer[j], outf); + fclose(outf); + } +} -- cgit v1.2.3