Skip to content

Commit

Permalink
Update wvWare wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Aug 22, 2024
1 parent 4299c5d commit 1596670
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ if(WITH_PDF2HTMLEX)
endif(WITH_PDF2HTMLEX)
if(WITH_WVWARE)
find_package(wvware REQUIRED)
target_link_libraries(odr PRIVATE wvware::wvware)
# target "meta" errors out if wvware is linked privately
target_link_libraries(odr PUBLIC wvware::wvware)
endif(WITH_WVWARE)

if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
Expand Down
15 changes: 12 additions & 3 deletions src/odr/internal/html/wvWare_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

extern "C" {
int convert(char *inputFile, char *outputDir, const char *password);
int no_graphics;
int no_graphics = 1;
int documentId = 0;

char *s_WVDATADIR = NULL;
char *s_HTMLCONFIG = NULL;
}

namespace odr::internal {
Expand All @@ -20,15 +24,20 @@ Html wvWare_wrapper(const File &file, const std::string &output_path,
throw FileNotFound();
}

// @TODO: getenv()
// s_WVDATADIR = NULL;
// s_HTMLCONFIG = NULL;

auto output_file_path = output_path + "/document.html";

char *input_file_path = strdup(disk_path->c_str());
char *output_dir = strdup(output_path.c_str());

no_graphics = 1;

g_htmlOutputFileHandle = fopen(output_file_path.c_str(), "w");

documentId++;

// @TODO: password
std::string password;
int retVal = convert(input_file_path, output_dir, password.c_str());
free(output_dir);
Expand Down
21 changes: 12 additions & 9 deletions src/wvWare.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* 02111-1307, USA.
*/

//#ifdef HAVE_CONFIG_H
#include <wv/config.h>
//#endif

#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -50,12 +48,6 @@
#define wvTrace( args )
#endif

/* strdup isn't declared in <string.h> for `gcc -ansi'; declare it here */
extern char *strdup (const char *);

extern char *str_copy(char *d, size_t n, char *s);
extern char *str_append(char *d, size_t n, char *s);

extern char *s_WVDATADIR;
extern char *s_HTMLCONFIG;
extern int documentId;
Expand All @@ -67,7 +59,18 @@ extern int documentId;
} \
}

extern char * strdup_and_append_twice(const char * a, const char * b, const char * c);
char *strdup_and_append_twice(const char *a, const char *b, const char *c) {
const size_t szA = strlen(a);
const size_t szB = strlen(b);
const size_t szC = strlen(c);

char *buf = malloc(szA + szB + szC + 1);
strcpy(buf, a);
strcpy(buf + szA, b);
strcpy(buf + szA + szB, c);
buf[szA + szB + szC] = '\0';
return buf;
}

/*
Released under GPL, written by Caolan.McNamara@ul.ie.
Expand Down

0 comments on commit 1596670

Please sign in to comment.