Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf79834870 | |||
| 4171c81bfd | |||
| 09b801c150 | |||
| 1807044977 |
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
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])
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||||
AC_CONFIG_SRCDIR([config.h.in])
|
AC_CONFIG_SRCDIR([config.h.in])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
|
|||||||
38
src/odt.c
38
src/odt.c
@@ -31,6 +31,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include "odt.h"
|
#include "odt.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ extractTemplateDocument(const char* const templateFilename, const char* const te
|
|||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
if ((child_pid = fork()) == 0) {
|
if ((child_pid = fork()) == 0) {
|
||||||
/* you are the child */
|
/* 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);
|
freopen("/dev/null", "w", stdout);
|
||||||
execvp("unzip", args);
|
execvp("unzip", args);
|
||||||
perror("execvp");
|
perror("execvp");
|
||||||
@@ -72,9 +73,40 @@ createOutputDocument(const char* const outputFilename, const char* const tempDir
|
|||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
if ((child_pid = fork()) == 0) {
|
if ((child_pid = fork()) == 0) {
|
||||||
/* you are the child */
|
/* 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];
|
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 };
|
char* const args[] = { "zip", "-r", outputRealPath, "mimetype", ".", NULL };
|
||||||
realpath(outputFilename, outputRealPath);
|
|
||||||
chdir(tempDir);
|
chdir(tempDir);
|
||||||
freopen("/dev/null", "w", stdout);
|
freopen("/dev/null", "w", stdout);
|
||||||
execvp("zip", args);
|
execvp("zip", args);
|
||||||
@@ -97,7 +129,7 @@ removeDirectory(const char* const tempDir) {
|
|||||||
pid_t child_pid;
|
pid_t child_pid;
|
||||||
if ((child_pid = fork()) == 0) {
|
if ((child_pid = fork()) == 0) {
|
||||||
/* you are the child */
|
/* 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);
|
freopen("/dev/null", "w", stdout);
|
||||||
execvp("rm", args);
|
execvp("rm", args);
|
||||||
perror("execvp");
|
perror("execvp");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#include <libxslt/xslt.h>
|
#include <libxslt/xslt.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user