Skip to content

Commit

Permalink
Update WVDATADIR setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Aug 25, 2024
1 parent 7dd61fc commit 05cb086
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ find_package(utf8cpp REQUIRED)
configure_file("src/odr/internal/project_info.cpp.in" "src/odr/internal/project_info.cpp")
configure_file("src/odr/internal/project_info.hpp.in" "src/odr/internal/project_info.hpp")

configure_file("src/wvWare.h.in" "src/wvWare.h")

set(PRE_CONFIGURE_FILE "src/odr/internal/git_info.cpp.in")
set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/src/odr/internal/git_info.cpp")
if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
Expand Down
2 changes: 2 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def generate(self):
tc.variables["ODR_TEST"] = False
tc.variables["WITH_PDF2HTMLEX"] = self.options.get_safe("with_pdf2htmlEX", False)
tc.variables["WITH_WVWARE"] = self.options.get_safe("with_wvWare", False)
if self.options.get_safe("with_wvWare", False):
tc.variables["WVDATADIR"] = self.dependencies['wvware'].cpp_info.resdirs[0]
tc.generate()

deps = CMakeDeps(self)
Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/project_info.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const char *version() noexcept;
} // namespace odr::internal::project_info

#cmakedefine WITH_PDF2HTMLEX 1
#cmakedefine WITH_WVWARE 1
#include <wvWare.h>

#endif // ODR_INTERNAL_PROJECT_INFO_HPP
21 changes: 15 additions & 6 deletions src/wvWare.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <wv/wv.h>
#include "getopt.h"

#include <wvWare.h>

#ifdef __ANDROID_API__
#include <android/log.h>
#define ParenthesesStripper(...) __VA_ARGS__
Expand All @@ -48,8 +50,6 @@
#define wvTrace( args )
#endif

char *s_WVDATADIR = NULL;
char *s_HTMLCONFIG = NULL;
int documentId = 0;

#define static_reinit( variable, defaultValue ) { \
Expand Down Expand Up @@ -1748,6 +1748,15 @@ myCharProc (wvParseStruct * ps, U16 eachchar, U8 chartype, U16 lid)
return (0);
}

const char *get_data_dir()
{
const char *data_dir = getenv("WVDATADIR");
if (NULL == data_dir) {
data_dir = WVDATADIR;
}
return data_dir;
}

int
wvOpenConfig (state_data *myhandle,char *config)
{
Expand All @@ -1765,18 +1774,18 @@ wvOpenConfig (state_data *myhandle,char *config)
if (NULL != buf) {
free(buf);
}
buf = strdup_and_append_twice(s_WVDATADIR, "/", config);
buf = strdup_and_append_twice(get_data_dir(), "/", config);
config = buf;
tmp = fopen(config, "rb");
}

if (tmp == NULL)
{
char * html_config = strdup_and_append_twice(get_data_dir(), "/", "wvHtml.xml");
if (i)
wvError (
("Attempt to open %s failed, using %s\n", config,
s_HTMLCONFIG));
config = s_HTMLCONFIG;
("Attempt to open %s failed, using %s\n", config, html_config));
config = html_config;
tmp = fopen (config, "rb");
}
myhandle->path = config;
Expand Down
7 changes: 7 additions & 0 deletions src/wvWare.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef WVWARE_H
#define WVWARE_H

#cmakedefine WITH_WVWARE 1
#cmakedefine WVDATADIR "@WVDATADIR@"

#endif //WVWARE_H

0 comments on commit 05cb086

Please sign in to comment.