Skip to content

Provide a hook to setup iconv path at runtime #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions oficonv/include/dcmtk/oficonv/iconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ DCMTK_OFICONV_EXPORT char *OFiconv_canonicalize(const char *name);
*/
DCMTK_OFICONV_EXPORT int OFiconvctl(iconv_t cd, int request, void *argument);

/** This function define a runtime path where to look for the oficonv db files.
* This path is used only after the env variable DCMICONVPATH.
* @param path to the location of esdb folder
*/
DCMTK_OFICONV_EXPORT void OFiconv_setpath(const char *iconv_path);

/// space holder type for OFlocale_charset().
typedef struct {
char spaceholder[20];
Expand Down
16 changes: 16 additions & 0 deletions oficonv/libsrc/citrus_bcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,25 @@
*/

#include "dcmtk/config/osconfig.h"
#include "dcmtk/oficonv/iconv.h"
#include "citrus_bcs.h"

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

char *oficonv_path = NULL;

void OFiconv_setpath(const char *runtime_path) {
if (oficonv_path) {
free(oficonv_path);
oficonv_path = NULL;
}
if (runtime_path) {
oficonv_path = strdup(runtime_path);
}
}

/*
* case insensitive comparison between two C strings.
*/
Expand Down Expand Up @@ -184,6 +197,9 @@ void get_data_path(char *path_out, size_t path_size, const char *dirname, const
// retrieve the DCMICONVPATH environment variable
env = getenv(OFICONV_PATH_VARIABLE);

// if the environment variable is not set, use the runtime oficonv path instead:
if ( env == NULL && oficonv_path != NULL ) env = oficonv_path;

// if the environment variable is not set, use DEFAULT_SUPPORT_DATA_DIR instead
if (env == NULL) env = DEFAULT_SUPPORT_DATA_DIR;

Expand Down
1 change: 1 addition & 0 deletions oficonv/libsrc/oficonv_iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,5 @@ const char *OFlocale_charset(iconv_locale_allocation_t *buf)
void OFiconv_cleanup()
{
_citrus_csmapper_free();
OFiconv_setpath(NULL);
}