/
| 1601 | |
| 1602 | /*****************************************************************************/ |
| 1603 | PJ_INFO proj_info (void) { |
| 1604 | /****************************************************************************** |
| 1605 | Basic info about the current instance of the PROJ.4 library. |
| 1606 | |
| 1607 | Returns PJ_INFO struct. |
| 1608 | ******************************************************************************/ |
| 1609 | size_t buf_size = 0; |
| 1610 | char *buf = nullptr; |
| 1611 | |
| 1612 | pj_acquire_lock (); |
| 1613 | |
| 1614 | info.major = PROJ_VERSION_MAJOR; |
| 1615 | info.minor = PROJ_VERSION_MINOR; |
| 1616 | info.patch = PROJ_VERSION_PATCH; |
| 1617 | |
| 1618 | /* This is a controlled environment, so no risk of sprintf buffer |
| 1619 | overflow. A normal version string is xx.yy.zz which is 8 characters |
| 1620 | long and there is room for 64 bytes in the version string. */ |
| 1621 | sprintf (version, "%d.%d.%d", info.major, info.minor, info.patch); |
| 1622 | |
| 1623 | info.version = version; |
| 1624 | info.release = pj_get_release (); |
| 1625 | |
| 1626 | /* build search path string */ |
| 1627 | auto ctx = pj_get_default_ctx(); |
| 1628 | if (ctx->search_paths.empty()) { |
| 1629 | const auto searchpaths = pj_get_default_searchpaths(ctx); |
| 1630 | for( const auto& path: searchpaths ) { |
| 1631 | buf = path_append(buf, path.c_str(), &buf_size); |
| 1632 | } |
| 1633 | } else { |
| 1634 | for (const auto &path : ctx->search_paths) { |
| 1635 | buf = path_append(buf, path.c_str(), &buf_size); |
| 1636 | } |
| 1637 | } |
| 1638 | |
| 1639 | free(const_cast<char*>(info.searchpath)); |
| 1640 | info.searchpath = buf ? buf : empty; |
| 1641 | |
| 1642 | info.paths = ctx->c_compat_paths; |
| 1643 | info.path_count = static_cast<int>(ctx->search_paths.size()); |
| 1644 | |
| 1645 | pj_release_lock (); |
| 1646 | return info; |
| 1647 | } |
| 1648 | |
| 1649 | |
| 1650 | /*****************************************************************************/ |
nothing calls this directly
no test coverage detected