#include #include #include #include extern "C" { #include "postgres.h" #include "fmgr.h" #include "utils/builtins.h" #include "utils/elog.h" } // #include "utl_compress.hpp" #include "../dbms_lob/dbms_lob.hpp" #include "../dbms_lob/dbms_lob_bfile.hpp" // zlib #include /// @brief Максимум одновременно открытых piecewise-хендлов на backend-процесс. #define UTLCOMP_MAX_HANDLE 5 /// @brief Версия RUDB пакета UTL_COMPRESS (Oracle UTL_COMPRESS пакет) #define RUDB_UTL_COMPRESS_VERSION "1.0.0" static constexpr int DBMS_LOB_FILE_READONLY = 0; // проверить значение namespace { /// @brief Размер внутреннего буфера для (де)флейта constexpr int DEF_CHUNK = 16384; // Ошибки [[noreturn]] void raise_invalid_argument(const char* msg = nullptr) { if (msg) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("UTL_COMPRESS.INVALID_ARGUMENT: %s", msg))); ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("UTL_COMPRESS.INVALID_ARGUMENT"))); } [[noreturn]] void raise_invalid_handle() { ereport(ERROR, (errcode(ERRCODE_INVALID_CURSOR_STATE), errmsg("UTL_COMPRESS.INVALID_HANDLE"))); } [[noreturn]] void raise_stream_error(const char* where) { ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), errmsg("UTL_COMPRESS.STREAM_ERROR at %s", where))); } [[noreturn]] void raise_data_error(const char* where) { ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), errmsg("UTL_COMPRESS.DATA_ERROR at %s", where))); } [[noreturn]] void raise_no_data_found() { ereport(ERROR, (errcode(ERRCODE_NO_DATA_FOUND), errmsg("UTL_COMPRESS.NO_DATA_FOUND: finished uncompress"))); } /// @brief Значение 0..15 по hex-символу, либо -1 inline int hexval(char c) { if (c >= '0' && c <= '9') return c - '0'; if (c >= 'a' && c <= 'f') return 10 + (c - 'a'); if (c >= 'A' && c <= 'F') return 10 + (c - 'A'); return -1; } /// @brief bytea -> вектор байт через byteaout("\\x...") static std::vector bytea_to_vec(bytea* src) { Datum cstrD = DirectFunctionCall1(byteaout, PointerGetDatum(src)); char* hex = DatumGetCString(cstrD); // palloc, освободим pfree size_t L = strlen(hex); if (L < 2 || hex[0] != '\\' || hex[1] != 'x') { pfree(hex); raise_data_error("byteaout format"); } size_t nbytes = (L - 2) / 2; std::vector out(nbytes); for (size_t i = 0; i < nbytes; ++i) { int hi = hexval(hex[2 + 2 * i]); int lo = hexval(hex[3 + 2 * i]); if (hi < 0 || lo < 0) { pfree(hex); raise_data_error("bytea hex parse"); } out[i] = (unsigned char)((hi << 4) | lo); } pfree(hex); return out; } /// @brief bytes -> bytea через byteain("\\x...") static bytea* buf_to_bytea(const unsigned char* data, size_t len) { size_t hexLen = 2 + 2 * len; char* hex = (char*) palloc(hexLen + 1); hex[0] = '\\'; hex[1] = 'x'; static const char* hc = "0123456789abcdef"; for (size_t i = 0; i < len; ++i) { unsigned char b = data[i]; hex[2 + 2 * i] = hc[b >> 4]; hex[3 + 2 * i] = hc[b & 0x0F]; } hex[hexLen] = '\0'; Datum d = DirectFunctionCall1(byteain, CStringGetDatum(hex)); pfree(hex); return (bytea*) DatumGetPointer(d); } /// @brief Упаковка std::vector в bytea static inline bytea* vec_to_bytea(const std::vector& v) { return buf_to_bytea(v.data(), v.size()); } /// @brief Одношаговое сжатие/распаковка gzip static std::vector gzip_compress(const unsigned char* src, size_t srclen, int level) { if (level < 1 || level > 9) raise_invalid_argument("quality must be in [1..9]"); z_stream strm; std::memset(&strm, 0, sizeof(strm)); int rc = deflateInit2(&strm, level, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) raise_stream_error("deflateInit2"); gz_header gzh; std::memset(&gzh, 0, sizeof(gzh)); gzh.time = 0; // gzip -n rc = deflateSetHeader(&strm, &gzh); if (rc != Z_OK) { deflateEnd(&strm); raise_stream_error("deflateSetHeader"); } std::vector out; out.reserve(std::max(srclen / 2, 64)); strm.next_in = const_cast(reinterpret_cast(src)); strm.avail_in = (uInt) srclen; unsigned char buf[DEF_CHUNK]; bool saw_end = false; do { strm.next_out = buf; strm.avail_out = sizeof(buf); rc = deflate(&strm, Z_FINISH); if (rc == Z_STREAM_ERROR) { deflateEnd(&strm); raise_stream_error("deflate"); } size_t have = sizeof(buf) - strm.avail_out; if (have) out.insert(out.end(), buf, buf + have); if (rc == Z_STREAM_END) saw_end = true; } while (rc != Z_STREAM_END); deflateEnd(&strm); if (!saw_end) raise_stream_error("deflate did not finish"); return out; } /// @brief Авто-распаковка (gzip/zlib) с контролем конца потока static std::vector auto_uncompress(const unsigned char* src, size_t srclen) { if (srclen == 0) raise_data_error("empty input"); z_stream strm; std::memset(&strm, 0, sizeof(strm)); int rc = inflateInit2(&strm, 15 + 32); // auto detect gzip/zlib if (rc != Z_OK) raise_stream_error("inflateInit2"); std::vector out; out.reserve(srclen * 2 + 64); strm.next_in = const_cast(reinterpret_cast(src)); strm.avail_in = (uInt) srclen; unsigned char buf[DEF_CHUNK]; bool saw_end = false; while (true) { strm.next_out = buf; strm.avail_out = sizeof(buf); rc = inflate(&strm, Z_NO_FLUSH); if (rc == Z_STREAM_END) { size_t have = sizeof(buf) - strm.avail_out; if (have) out.insert(out.end(), buf, buf + have); saw_end = true; break; } if (rc == Z_NEED_DICT || rc == Z_DATA_ERROR) { inflateEnd(&strm); raise_data_error("inflate"); } if (rc == Z_STREAM_ERROR) { inflateEnd(&strm); raise_stream_error("inflate"); } size_t have = sizeof(buf) - strm.avail_out; if (have) out.insert(out.end(), buf, buf + have); if (rc != Z_OK && rc != Z_BUF_ERROR) break; if (strm.avail_in == 0 && strm.avail_out == sizeof(buf)) break; // ничего не происходит } inflateEnd(&strm); if (!saw_end) raise_data_error("truncated or invalid stream"); return out; } /// @brief Контекст компрессии (piecewise) struct CtxC { bool in_use = false; bool finished = false; z_stream strm{}; gz_header gzh{}; // держим заголовок живым для deflateSetHeader std::vector out; }; /// @brief контекст распаковки (piecewise) struct CtxU { bool in_use = false; bool finished = false; z_stream strm{}; std::vector in; // сжатые данные size_t in_pos = 0; }; static CtxC g_comp[UTLCOMP_MAX_HANDLE]; static CtxU g_unco[UTLCOMP_MAX_HANDLE]; /// @brief Выделить контекст компрессии и инициализировать zlib int alloc_comp_ctx(int level) { if (level < 1 || level > 9) raise_invalid_argument("quality must be in [1..9]"); for (int i = 0; i < UTLCOMP_MAX_HANDLE; ++i) { if (!g_comp[i].in_use) { CtxC& c = g_comp[i]; c = CtxC{}; c.in_use = true; int rc = deflateInit2(&c.strm, level, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { c.in_use = false; raise_stream_error("deflateInit2"); } std::memset(&c.gzh, 0, sizeof(c.gzh)); c.gzh.time = 0; // gzip rc = deflateSetHeader(&c.strm, &c.gzh); if (rc != Z_OK) { deflateEnd(&c.strm); c.in_use = false; raise_stream_error("deflateSetHeader"); } c.out.clear(); return i + 1; // handle } } raise_invalid_handle(); return 0; } /// @brief Получить ссылку на контекст компрессии по handle CtxC& get_comp_ctx(int handle) { if (handle <= 0 || handle > UTLCOMP_MAX_HANDLE) raise_invalid_handle(); CtxC& c = g_comp[handle - 1]; if (!c.in_use) raise_invalid_handle(); return c; } /// @brief Освободить контекст компрессии void free_comp_ctx(int handle) { CtxC& c = get_comp_ctx(handle); deflateEnd(&c.strm); c = CtxC{}; } /// @brief Выделить контекст распаковки и инициализировать zlib int alloc_unco_ctx(bytea* src) { auto bytes = bytea_to_vec(src); for (int i = 0; i < UTLCOMP_MAX_HANDLE; ++i) { if (!g_unco[i].in_use) { CtxU& u = g_unco[i]; u = CtxU{}; u.in_use = true; u.in.swap(bytes); u.in_pos = 0; int rc = inflateInit2(&u.strm, 15 + 32); // auto detect if (rc != Z_OK) { u.in_use = false; raise_stream_error("inflateInit2"); } return i + 1; } } raise_invalid_handle(); return 0; } /// @brief Получить ссылку на контекст распаковки по handle CtxU& get_unco_ctx(int handle) { if (handle <= 0 || handle > UTLCOMP_MAX_HANDLE) raise_invalid_handle(); CtxU& u = g_unco[handle - 1]; if (!u.in_use) raise_invalid_handle(); return u; } /// @brief Освободить контекст распаковки void free_unco_ctx(int handle) { CtxU& u = get_unco_ctx(handle); inflateEnd(&u.strm); u = CtxU{}; } } // namespace extern "C" { // ===== ISOPEN ===== /* * @qdb_func: utl_compress_isopen(int4) * @ora_func: UTL_COMPRESS.ISOPEN(BINARY_INTEGER) */ Datum utl_compress_isopen(PG_FUNCTION_ARGS) { int32 handle = PG_GETARG_INT32(0); if (handle <= 0 || handle > UTLCOMP_MAX_HANDLE) PG_RETURN_BOOL(false); bool opened = g_comp[handle - 1].in_use || g_unco[handle - 1].in_use; PG_RETURN_BOOL(opened); } // ===== One-shot LZ_COMPRESS / RAW ===== Datum utl_compress_lz_compress_raw(PG_FUNCTION_ARGS) { if (PG_ARGISNULL(0)) PG_RETURN_NULL(); bytea* src = PG_GETARG_BYTEA_PP(0); int32 level = (PG_NARGS() > 1 && !PG_ARGISNULL(1)) ? PG_GETARG_INT32(1) : 6; auto bytes = bytea_to_vec(src); auto out = gzip_compress(bytes.data(), bytes.size(), level); PG_RETURN_BYTEA_P(vec_to_bytea(out)); } // ===== One-shot LZ_COMPRESS / BLOB ===== Datum utl_compress_lz_compress_blob(PG_FUNCTION_ARGS) { if (PG_ARGISNULL(0)) PG_RETURN_NULL(); bytea* src = PG_GETARG_BYTEA_PP(0); int32 level = (PG_NARGS() > 1 && !PG_ARGISNULL(1)) ? PG_GETARG_INT32(1) : 6; auto bytes = bytea_to_vec(src); auto out = gzip_compress(bytes.data(), bytes.size(), level); PG_RETURN_BYTEA_P(vec_to_bytea(out)); } // ===== One-shot LZ_UNCOMPRESS / RAW ===== Datum utl_compress_lz_uncompress_raw(PG_FUNCTION_ARGS) { if (PG_ARGISNULL(0)) PG_RETURN_NULL(); bytea* src = PG_GETARG_BYTEA_PP(0); LOCAL_FCINFO(local_fcinfo, 2); InitFunctionCallInfoData(*local_fcinfo, NULL, 2, PG_GET_COLLATION(), fcinfo->context, NULL); local_fcinfo->args[0].value = PointerGetDatum(src); local_fcinfo->args[0].isnull = fcinfo->args[0].isnull; local_fcinfo->args[1].value = DatumGetBool(false); local_fcinfo->args[1].isnull = false; PG_RETURN_DATUM( (*utl_compress_lz_uncompress_raw_common) (local_fcinfo)); } Datum utl_compress_lz_uncompress_raw_common(PG_FUNCTION_ARGS) { bool onempty = PG_ARGISNULL(1) ? false : PG_GETARG_BOOL(1); if (PG_ARGISNULL(0)) { if(onempty){ std::vector vec; PG_RETURN_BYTEA_P(vec_to_bytea(vec)); } PG_RETURN_NULL(); } bytea* src = PG_GETARG_BYTEA_PP(0); auto bytes = bytea_to_vec(src); auto out = auto_uncompress(bytes.data(), bytes.size()); PG_RETURN_BYTEA_P(vec_to_bytea(out)); } // ===== One-shot LZ_UNCOMPRESS / BLOB ===== Datum utl_compress_lz_uncompress_blob(PG_FUNCTION_ARGS) { if (PG_ARGISNULL(0)) PG_RETURN_NULL(); bytea* src = PG_GETARG_BYTEA_PP(0); auto bytes = bytea_to_vec(src); auto out = auto_uncompress(bytes.data(), bytes.size()); PG_RETURN_BYTEA_P(vec_to_bytea(out)); } // ===== Piecewise: OPEN ===== /* * @qdb_func: utl_compress_lz_compress_open(blob) * @ora_func: UTL_COMPRESS.LZ_COMPRESS_OPEN(BLOB, BINARY_INTEGER) */ Datum utl_compress_lz_compress_open(PG_FUNCTION_ARGS) { int32 level = (PG_NARGS() > 1 && !PG_ARGISNULL(1)) ? PG_GETARG_INT32(1) : 6; int handle = alloc_comp_ctx(level); PG_RETURN_INT32(handle); } // ===== Piecewise: ADD ===== /* * @qdb_func: utl_compress_lz_compress_add(int4, blob, raw) * @ora_func: UTL_COMPRESS.LZ_COMPRESS_ADD(BINARY_INTEGER, BLOB, RAW) */ Datum utl_compress_lz_compress_add(PG_FUNCTION_ARGS) { int32 handle = PG_GETARG_INT32(0); // dst (BLOB) игнорируем — копим во внутреннем буфере if (PG_ARGISNULL(2)) PG_RETURN_VOID(); bytea* src = PG_GETARG_BYTEA_PP(2); CtxC& c = get_comp_ctx(handle); auto bytes = bytea_to_vec(src); c.strm.next_in = const_cast(reinterpret_cast(bytes.data())); c.strm.avail_in = (uInt) bytes.size(); unsigned char buf[DEF_CHUNK]; while (c.strm.avail_in > 0) { c.strm.next_out = buf; c.strm.avail_out = sizeof(buf); int rc = deflate(&c.strm, Z_NO_FLUSH); if (rc == Z_STREAM_ERROR) raise_stream_error("deflate(NO_FLUSH)"); size_t have = sizeof(buf) - c.strm.avail_out; if (have) c.out.insert(c.out.end(), buf, buf + have); } PG_RETURN_VOID(); } // ===== Piecewise: CLOSE ===== /* * @qdb_func: utl_compress_lz_compress_close(int4, blob) * @ora_func: UTL_COMPRESS.LZ_COMPRESS_CLOSE(BINARY_INTEGER, BLOB) */ Datum utl_compress_lz_compress_close(PG_FUNCTION_ARGS) { int32 handle = PG_GETARG_INT32(0); CtxC& c = get_comp_ctx(handle); unsigned char buf[DEF_CHUNK]; bool saw_end = false; while (true) { c.strm.next_out = buf; c.strm.avail_out = sizeof(buf); int rc = deflate(&c.strm, Z_FINISH); if (rc == Z_STREAM_END) { size_t have = sizeof(buf) - c.strm.avail_out; if (have) c.out.insert(c.out.end(), buf, buf + have); saw_end = true; break; } if (rc == Z_OK) { size_t have = sizeof(buf) - c.strm.avail_out; if (have) c.out.insert(c.out.end(), buf, buf + have); continue; } raise_stream_error("deflate(FINISH)"); } deflateEnd(&c.strm); if (!saw_end) raise_stream_error("deflate did not finish"); bytea* ret = vec_to_bytea(c.out); c = CtxC{}; PG_RETURN_BYTEA_P(ret); } // ===== Piecewise UNCOMPRESS: OPEN ===== /* * @qdb_func: utl_compress_lz_uncompress_open(blob) * @ora_func: UTL_COMPRESS.LZ_UNCOMPRESS_OPEN(BLOB) */ Datum utl_compress_lz_uncompress_open(PG_FUNCTION_ARGS) { if (PG_ARGISNULL(0)) raise_invalid_argument("NULL src"); bytea* src = PG_GETARG_BYTEA_PP(0); int handle = alloc_unco_ctx(src); PG_RETURN_INT32(handle); } // ===== Piecewise UNCOMPRESS: EXTRACT ===== /* * @qdb_func: utl_compress_lz_uncompress_extract(int4) * @ora_func: UTL_COMPRESS.LZ_UNCOMPRESS_EXTRACT(BINARY_INTEGER, RAW) */ Datum utl_compress_lz_uncompress_extract(PG_FUNCTION_ARGS) { int32 handle = PG_GETARG_INT32(0); int32 max_chunk = (PG_NARGS() > 1 && !PG_ARGISNULL(1)) ? PG_GETARG_INT32(1) : 8192; if (max_chunk <= 0) raise_invalid_argument("max_chunk_size must be > 0"); CtxU& u = get_unco_ctx(handle); if (u.finished) raise_no_data_found(); unsigned char* outbuf = (unsigned char*) palloc(max_chunk); size_t produced_total = 0; int rc = Z_OK; while (produced_total < (size_t)max_chunk) { if (u.strm.avail_in == 0 && u.in_pos < u.in.size()) { size_t feed = std::min(u.in.size() - u.in_pos, (size_t)DEF_CHUNK); u.strm.next_in = (Bytef*)(u.in.data() + u.in_pos); u.strm.avail_in = (uInt) feed; u.in_pos += feed; } u.strm.next_out = outbuf + produced_total; u.strm.avail_out = (uInt)(max_chunk - produced_total); rc = inflate(&u.strm, Z_NO_FLUSH); if (rc == Z_STREAM_END) { size_t step = (max_chunk - produced_total) - u.strm.avail_out; produced_total += step; u.finished = true; break; } if (rc == Z_NEED_DICT || rc == Z_DATA_ERROR) { pfree(outbuf); raise_data_error("inflate(extract)"); } if (rc == Z_STREAM_ERROR) { pfree(outbuf); raise_stream_error("inflate(extract)"); } size_t step = (max_chunk - produced_total) - u.strm.avail_out; produced_total += step; if (step > 0) break; // отдали что-то if (u.strm.avail_in == 0 && u.in_pos >= u.in.size() && rc == Z_OK) break; // вход закончился } if (produced_total == 0) { pfree(outbuf); raise_no_data_found(); } bytea* ret = buf_to_bytea(outbuf, produced_total); pfree(outbuf); PG_RETURN_BYTEA_P(ret); } // ===== Piecewise UNCOMPRESS: CLOSE ===== /* * @qdb_func: utl_compress_lz_uncompress_close(int4) * @ora_func: UTL_COMPRESS.LZ_UNCOMPRESS_CLOSE(BINARY_INTEGER) */ Datum utl_compress_lz_uncompress_close(PG_FUNCTION_ARGS) { int32 handle = PG_GETARG_INT32(0); free_unco_ctx(handle); PG_RETURN_VOID(); } Datum utl_compress_lz_compress_bfile(PG_FUNCTION_ARGS) { if (PG_ARGISNULL(0)) PG_RETURN_NULL(); Datum bfileD = PG_GETARG_DATUM(0); int32 level = (PG_NARGS() > 1 && !PG_ARGISNULL(1)) ? PG_GETARG_INT32(1) : 6; if (level < 1 || level > 9) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("UTL_COMPRESS.INVALID_ARGUMENT: quality must be in [1..9]"))); } const int READ_CHUNK = 65536; // 64 KiB const int FILE_READONLY = DBMS_LOB_FILE_READONLY; // проверь код у себя (обычно 0) bool opened_here = false; // Проверяем, открыт ли уже BFILE bool already_open = false; { Datum r = DirectFunctionCall1(dbms_lob_fileisopen, bfileD); already_open = (DatumGetBool(r) || DatumGetInt32(r) != 0); } if (!already_open) { (void) DirectFunctionCall2(dbms_lob_fileopen, bfileD, Int32GetDatum(FILE_READONLY)); opened_here = true; } // zlib: gzip (-n) z_stream strm; std::memset(&strm, 0, sizeof(strm)); int rc = deflateInit2(&strm, level, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { if (opened_here) (void) DirectFunctionCall1(dbms_lob_fileclose, bfileD); ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), errmsg("UTL_COMPRESS.STREAM_ERROR at deflateInit2"))); } gz_header gzh; std::memset(&gzh, 0, sizeof(gzh)); gzh.time = 0; rc = deflateSetHeader(&strm, &gzh); if (rc != Z_OK) { deflateEnd(&strm); if (opened_here) (void) DirectFunctionCall1(dbms_lob_fileclose, bfileD); ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), errmsg("UTL_COMPRESS.STREAM_ERROR at deflateSetHeader"))); } std::vector out; out.reserve(8192); unsigned char zbuf[16384]; int32 offset = 1; // Oracle-style 1-based PG_TRY(); { // Читаем BFILE кусками и подаём в deflate while (true) { bytea* chunk = BFileManager::ReadFile( DatumGetTextPP(bfileD), offset - 1, READ_CHUNK); auto bytes = bytea_to_vec(chunk); size_t got = bytes.size(); pfree(chunk); if (got == 0) break; strm.next_in = const_cast(reinterpret_cast(bytes.data())); strm.avail_in = (uInt) got; while (strm.avail_in > 0) { strm.next_out = zbuf; strm.avail_out = sizeof(zbuf); rc = deflate(&strm, Z_NO_FLUSH); if (rc == Z_STREAM_ERROR) { ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), errmsg("UTL_COMPRESS.STREAM_ERROR at deflate(NO_FLUSH)"))); } size_t have = sizeof(zbuf) - strm.avail_out; if (have) out.insert(out.end(), zbuf, zbuf + have); } offset += (int32) got; if ((int32)got < READ_CHUNK) break; // EOF } // Завершаем поток while (true) { strm.next_out = zbuf; strm.avail_out = sizeof(zbuf); rc = deflate(&strm, Z_FINISH); if (rc == Z_STREAM_END) { size_t have = sizeof(zbuf) - strm.avail_out; if (have) out.insert(out.end(), zbuf, zbuf + have); break; } if (rc == Z_OK) { size_t have = sizeof(zbuf) - strm.avail_out; if (have) out.insert(out.end(), zbuf, zbuf + have); continue; } ereport(ERROR, (errcode(ERRCODE_EXTERNAL_ROUTINE_EXCEPTION), errmsg("UTL_COMPRESS.STREAM_ERROR at deflate(FINISH)"))); } deflateEnd(&strm); if (opened_here) (void) DirectFunctionCall1(dbms_lob_fileclose, bfileD); PG_RETURN_BYTEA_P(vec_to_bytea(out)); } PG_CATCH(); { // Освобождение ресурсов при исключении deflateEnd(&strm); if (opened_here) (void) DirectFunctionCall1(dbms_lob_fileclose, bfileD); PG_RE_THROW(); } PG_END_TRY(); } /// @brief Возвращает версию RUDB пакета UTL_COMPRESS (Oracle UTL_COMPRESS пакет) Datum utl_compress_get_version(PG_FUNCTION_ARGS) { PG_RETURN_TEXT_P(cstring_to_text(RUDB_UTL_COMPRESS_VERSION)); } } // extern "C"