/
| 210 | |
| 211 | /************************************************************************/ |
| 212 | static paralist *get_init(PJ_CONTEXT *ctx, const char *key, |
| 213 | int allow_init_epsg) { |
| 214 | /************************************************************************* |
| 215 | Expand key from buffer or (if not in buffer) from init file |
| 216 | *************************************************************************/ |
| 217 | const char *xkey; |
| 218 | char *definition = nullptr; |
| 219 | paralist *init_items = nullptr; |
| 220 | |
| 221 | if (!ctx) { |
| 222 | ctx = pj_get_default_ctx(); |
| 223 | } |
| 224 | |
| 225 | /* support "init=file:section", "+init=file:section", and "file:section" |
| 226 | * format */ |
| 227 | xkey = strstr(key, "init="); |
| 228 | if (nullptr == xkey) |
| 229 | xkey = key; |
| 230 | else |
| 231 | xkey += 5; |
| 232 | pj_log(ctx, PJ_LOG_TRACE, "get_init: searching cache for key: [%s]", xkey); |
| 233 | |
| 234 | /* Is file/key pair already in cache? */ |
| 235 | init_items = pj_search_initcache(xkey); |
| 236 | if (init_items) |
| 237 | return init_items; |
| 238 | |
| 239 | if ((strncmp(xkey, "epsg:", 5) == 0 || strncmp(xkey, "IGNF:", 5) == 0)) { |
| 240 | char unused[256]; |
| 241 | char initname[5]; |
| 242 | int exists; |
| 243 | |
| 244 | strncpy(initname, xkey, 4); |
| 245 | initname[4] = 0; |
| 246 | |
| 247 | if (strncmp(xkey, "epsg:", 5) == 0) { |
| 248 | exists = ctx->epsg_file_exists; |
| 249 | if (exists < 0) { |
| 250 | exists = pj_find_file(ctx, initname, unused, sizeof(unused)); |
| 251 | ctx->epsg_file_exists = exists; |
| 252 | } |
| 253 | } else { |
| 254 | exists = pj_find_file(ctx, initname, unused, sizeof(unused)); |
| 255 | } |
| 256 | |
| 257 | if (!exists) { |
| 258 | char szInitStr[7 + 64]; |
| 259 | PJ *src; |
| 260 | const char *proj_string; |
| 261 | |
| 262 | proj_context_errno_set(ctx, 0); |
| 263 | |
| 264 | if (!allow_init_epsg) { |
| 265 | pj_log(ctx, PJ_LOG_TRACE, "%s expansion disallowed", xkey); |
| 266 | return nullptr; |
| 267 | } |
| 268 | if (strlen(xkey) > 64) { |
| 269 | return nullptr; |
no test coverage detected