#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); } }