4 Commits
v1.4 ... v1.5

Author SHA1 Message Date
cf79834870 Pointer qualifier fix 2025-08-05 12:03:50 -04:00
4171c81bfd Bump version number 2025-08-05 11:39:41 -04:00
09b801c150 Fix missing #includes 2025-08-02 21:16:32 -04:00
1807044977 Account for different implementations of realpath(3) 2025-06-05 11:06:49 -04:00
4 changed files with 38 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([sermon], [1.4], [david.a.baer@gmail.com])
AC_INIT([sermon], [1.5], [david.a.baer@gmail.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])

View File

@@ -27,6 +27,7 @@
*
*/
#include <ctype.h>
#include <string.h>
#include "queue.h"
#include "stack.h"

View File

@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include "odt.h"
#include "options.h"
@@ -50,7 +51,7 @@ extractTemplateDocument(const char* const templateFilename, const char* const te
pid_t child_pid;
if ((child_pid = fork()) == 0) {
/* you are the child */
char* const args[] = { "unzip", "-d", tempDir, templateFilename, NULL };
char* const args[] = { "unzip", "-d", (char* const)tempDir, (char* const)templateFilename, NULL };
freopen("/dev/null", "w", stdout);
execvp("unzip", args);
perror("execvp");
@@ -72,9 +73,40 @@ createOutputDocument(const char* const outputFilename, const char* const tempDir
pid_t child_pid;
if ((child_pid = fork()) == 0) {
/* you are the child */
/* In some implementations, realpath will give an error
* if the file does not exist, so we need to run it on
* the output directory, not the as-yet nonexistent
* output filename. That's what all this (below) is for. */
char outputDir[FILENAME_MAX];
char outputBase[FILENAME_MAX];
char outputRealPath[FILENAME_MAX];
strncpy(outputDir, outputFilename, FILENAME_MAX);
char *ptr = strrchr(outputDir, '/');
if (ptr) {
strncpy(outputBase, ptr + 1, FILENAME_MAX);
*(ptr + 1) = '\0';
} else {
strncpy(outputDir, ".", FILENAME_MAX);
strncpy(outputBase, outputFilename, FILENAME_MAX);
}
if (realpath(outputDir, outputRealPath) == NULL) {
/* hopefully this doesn't run, but it will give good info
* if it does */
perror("realpath");
fprintf(stderr, "outputFilename was \"%s\"\n", outputFilename);
char curdir[FILENAME_MAX];
getcwd(curdir, FILENAME_MAX);
fprintf(stderr, "curdir was \"%s\"\n", curdir);
exit(1);
}
/* Then we append the output filename. */
strncat(outputRealPath, "/", FILENAME_MAX);
strncat(outputRealPath, outputBase, FILENAME_MAX);
char* const args[] = { "zip", "-r", outputRealPath, "mimetype", ".", NULL };
realpath(outputFilename, outputRealPath);
chdir(tempDir);
freopen("/dev/null", "w", stdout);
execvp("zip", args);
@@ -97,7 +129,7 @@ removeDirectory(const char* const tempDir) {
pid_t child_pid;
if ((child_pid = fork()) == 0) {
/* you are the child */
char* const args[] = { "rm", "-rf", tempDir, NULL };
char* const args[] = { "rm", "-rf", (char* const)tempDir, NULL };
freopen("/dev/null", "w", stdout);
execvp("rm", args);
perror("execvp");

View File

@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/tree.h>
#include <libxslt/xslt.h>