summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-09-27 19:32:15 +0200
committerCarl Hetherington <cth@carlh.net>2020-09-27 19:33:09 +0200
commit627dfd9a5cdcce9e4122ef3041a38c3da2d3a120 (patch)
treea250e81f9d6b746bfbadb2428dbdea8c1ac1de6d /src/util.cc
parentf3e69079eefa18407b110ff23df26f7711ebf7e5 (diff)
Load language tags from on-disk files rather than embedding them
into a .cc. The .cc method causes compile times (and memory requirements) increase enormously with some compilers.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/util.cc b/src/util.cc
index 009d5bae..211f03f8 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -36,6 +36,7 @@
*/
#include "util.h"
+#include "language_tag.h"
#include "exceptions.h"
#include "types.h"
#include "certificate.h"
@@ -173,9 +174,13 @@ dcp::empty_or_white_space (string s)
/** Set up various bits that the library needs. Should be called once
* by client applications.
+ *
+ * @param tags_directory Path to a copy of the tags directory from the source code;
+ * if none is specified libdcp will look for a tags directory inside the environment
+ * variable LIBDCP_SHARE_PREFIX or the LIBDCP_SHARE_PREFIX #defined during the build.
*/
void
-dcp::init ()
+dcp::init (optional<boost::filesystem::path> tags_directory)
{
if (xmlSecInit() < 0) {
throw MiscError ("could not initialise xmlsec");
@@ -198,6 +203,17 @@ dcp::init ()
OpenSSL_add_all_algorithms();
asdcp_smpte_dict = &ASDCP::DefaultSMPTEDict();
+
+ if (!tags_directory) {
+ char* prefix = getenv("LIBDCP_SHARE_PREFIX");
+ if (prefix) {
+ tags_directory = boost::filesystem::path(prefix) / "tags";
+ } else {
+ tags_directory = LIBDCP_SHARE_PREFIX "/tags";
+ }
+ }
+
+ load_language_tag_lists (*tags_directory);
}
/** Decode a base64 string. The base64 decode routine in KM_util.cpp
@@ -452,4 +468,3 @@ ASDCPErrorSuspender::~ASDCPErrorSuspender ()
delete _sink;
}
-