diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-01-09 18:30:17 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-01-09 19:45:21 +0100 |
| commit | 3cc9336b038118de424d018dd0bdd90e329ad8c1 (patch) | |
| tree | 790ceaa32d7217f7667264217ecdec6db5c5d3b9 /src/4D_api.cpp | |
| parent | d6dad2cee4307f6b190a96dd48942645060919cc (diff) | |
| download | PROJ-3cc9336b038118de424d018dd0bdd90e329ad8c1.tar.gz PROJ-3cc9336b038118de424d018dd0bdd90e329ad8c1.zip | |
proj.h: add proj_context_set_file_finder() and proj_context_set_search_paths() (refs #1150)
Diffstat (limited to 'src/4D_api.cpp')
| -rw-r--r-- | src/4D_api.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp index e0d15773..cdfaa8b2 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -1006,7 +1006,6 @@ static char *path_append (char *buf, const char *app, size_t *buf_size) { static const char *empty = {""}; static char version[64] = {""}; static PJ_INFO info = {0, 0, 0, nullptr, nullptr, nullptr, nullptr, 0}; -static volatile int info_initialized = 0; /*****************************************************************************/ PJ_INFO proj_info (void) { @@ -1015,19 +1014,11 @@ PJ_INFO proj_info (void) { Returns PJ_INFO struct. ******************************************************************************/ - const char * const *paths; - size_t i, n; - size_t buf_size = 0; char *buf = nullptr; pj_acquire_lock (); - if (0!=info_initialized) { - pj_release_lock (); - return info; - } - info.major = PROJ_VERSION_MAJOR; info.minor = PROJ_VERSION_MINOR; info.patch = PROJ_VERSION_PATCH; @@ -1037,7 +1028,6 @@ PJ_INFO proj_info (void) { long and there is room for 64 bytes in the version string. */ sprintf (version, "%d.%d.%d", info.major, info.minor, info.patch); - info.searchpath = empty; info.version = version; info.release = pj_get_release (); @@ -1045,17 +1035,19 @@ PJ_INFO proj_info (void) { buf = path_append (buf, getenv ("HOME"), &buf_size); buf = path_append (buf, getenv ("PROJ_LIB"), &buf_size); - paths = proj_get_searchpath (); - n = (size_t) proj_get_path_count (); + auto ctx = pj_get_default_ctx(); + if( ctx ) { + for( const auto& path: ctx->search_paths ) { + buf = path_append(buf, path.c_str(), &buf_size); + } + } - for (i = 0; i < n; i++) - buf = path_append (buf, paths[i], &buf_size); + pj_dalloc(const_cast<char*>(info.searchpath)); info.searchpath = buf ? buf : empty; - info.paths = paths; - info.path_count = n; + info.paths = ctx ? ctx->c_compat_paths : nullptr; + info.path_count = ctx ? static_cast<int>(ctx->search_paths.size()) : 0; - info_initialized = 1; pj_release_lock (); return info; } |
