/* WARNING: This file was generated by dkct. Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4dbia.ctr */ /* Copyright (C) 2015-2017, Dirk Krause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above opyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @file dk4dbia.c The dk4dbia module. */ #line 128 "dk4dbia.ctr" #include "dk4dbia.h" #include "dk4const.h" #line 136 "dk4dbia.ctr" /** Preference names we are using here. */ static const dkChar * const dk4dbi_pref_names[] = { /* 0 */ dkT("db.key.max-size"), /* 1 */ dkT("db.value.max-size"), NULL #line 146 "dk4dbia.ctr" }; /** Constant texts used by the module, not localized. */ static const dkChar * const dk4dbia_kwnl[] = { /* 0 */ dkT("dk4dbia.str"), NULL #line 159 "dk4dbia.ctr" }; /** Constant texts used by the module, localized texts are used if available. */ static const dkChar * const dk4dbia_kw_def[] = { /* 0 */ dkT("Failed to open database!"), /* 1 */ dkT("\nInvalid arguments were provided to the DB opening function."), /* 2 */ dkT("\nThe database type is not supported."), /* 3 */ dkT("\nMathematical overflow in size calculation."), /* 4 */ dkT("\nInsufficient memory available."), /* 5 */ dkT("\nSyntax error (database name, file type or file contents)."), /* 6 */ dkT("\nInsufficient permissions."), /* 7 */ dkT("\nFailed to open the file for read access."), /* 8 */ dkT("\nFailed to open the file for write access."), /* 9 */ dkT("\nFailed to close the file."), NULL #line 209 "dk4dbia.ctr" }; dk4_dbi_t * dk4dbi_open_sizes_app( const dkChar *fn, int wa, int tr, size_t km, size_t vm, dk4_er_t *erp, dk4_app_t *app ) { dk4_er_t er; /* Error report from dk4dbi_open */ const dkChar * parts[4]; /* Message parts array */ const dkChar * const *msg = NULL; /* Localized messages */ dk4_dbi_t *back = NULL; /* Result */ size_t szpts = 0; /* Number of elements in parts */ dk4error_init(&er); back = dk4dbi_open(fn, wa, tr, km, vm, &er); if (NULL == back) { dk4error_copy(erp, &er); if (NULL != app) { msg = dk4app_string_table(app, dk4dbia_kwnl[0], dk4dbia_kw_def); parts[0] = msg[0]; parts[1] = NULL; szpts = 1; switch (er.ec) { case DK4_E_INVALID_ARGUMENTS : { parts[1] = msg[1]; parts[2] = NULL; szpts = 2; } break; case DK4_E_NOT_SUPPORTED : { parts[1] = msg[2]; parts[2] = NULL; szpts = 2; } break; case DK4_E_MATH_OVERFLOW : { parts[1] = msg[3]; parts[2] = NULL; szpts = 2; } break; case DK4_E_MEMORY_ALLOCATION_FAILED : { parts[1] = msg[4]; parts[2] = NULL; szpts = 2; } break; case DK4_E_SYNTAX : { parts[1] = msg[5]; parts[2] = NULL; szpts = 2; } break; case DK4_E_SEC_CHECK : { parts[1] = msg[6]; parts[2] = NULL; szpts = 2; } break; case DK4_E_OPEN_READ_FAILED : { parts[1] = msg[7]; parts[2] = NULL; szpts = 2; } break; case DK4_E_OPEN_WRITE_FAILED : { parts[1] = msg[8]; parts[2] = NULL; szpts = 2; } break; case DK4_E_CLOSE_FAILED : { parts[1] = msg[9]; parts[2] = NULL; szpts = 2; } break; } if (0 < szpts) { dk4app_log_msg(app, DK4_LL_ERROR, parts, szpts); } } } return back; } dk4_dbi_t * dk4dbi_open_app( const dkChar *fn, int wa, int tr, dk4_er_t *erp, dk4_app_t *app ) { size_t km = 0; size_t vm = 0; if (0 == dk4app_pref_get_size(&km, app, dk4dbi_pref_names[0], 0)) { km = 0; } if (0 == dk4app_pref_get_size(&vm, app, dk4dbi_pref_names[1], 0)) { vm = 0; } return (dk4dbi_open_sizes_app(fn, wa, tr, km, vm, erp, app)); }