/* 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: dk4aprgs.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 dk4aprgs.c The dk4aprgs module. */ #line 10 "dk4aprgs.ctr" #include "dk4conf.h" #include "dk4types.h" #include "dk4app.h" #include "dk4pref.h" #include "dk4strd.h" #include "dk4appi.c" #include "dk4mem.h" #include "dk4enc.h" #include "dk4maidddi.h" #include "dk4maidddu.h" #include "dk4maiddsz.h" #include "dk4maodd.h" #line 27 "dk4aprgs.ctr" int dk4app_pref_get( dkChar *dptr, size_t szdptr, dk4_app_t *app, const dkChar *name, int excl ) { dk4_pref_t *pptr = NULL; int back = 0; #line 42 "dk4aprgs.ctr" if ((NULL != dptr) && (0 < szdptr) && (NULL != app) && (NULL != name)) { if (0 == (excl & DK4_APP_PREF_SRC_SELF)) { pptr = dk4sto_it_find_like(app->i_pref_self, name, 1); } if ((NULL == pptr) && (0 == (excl & DK4_APP_PREF_SRC_CMD))) { pptr = dk4sto_it_find_like(app->i_pref_cmd, name, 1); } if ((NULL == pptr) && (0 == (excl & DK4_APP_PREF_SRC_USER))) { pptr = dk4sto_it_find_like(app->i_pref_user, name, 1); } if ((NULL == pptr) && (0 == (excl & DK4_APP_PREF_SRC_SYSTEM))) { pptr = dk4sto_it_find_like(app->i_pref_sys, name, 1); } if (NULL != pptr) { if (0 != dk4str_cpy_s(dptr, szdptr, pptr->value, NULL)) { back = 1; if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { dk4app_log_base5(app,DK4_LL_DEBUG,160,161,162,name,pptr->value); } } else { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { dk4app_log_base5(app,DK4_LL_DEBUG,163,164,165,name,pptr->value); } } } else { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { dk4app_log_base3(app, DK4_LL_DEBUG, 166, 167, name); } } } #line 72 "dk4aprgs.ctr" return back; } int dk4app_pref_get_int( dk4_im_t *dptr, dk4_app_t *app, const dkChar *name, int excl ) { dkChar buf[64]; const dkChar *endptr; dk4_im_t val; int back = 0; #line 90 "dk4aprgs.ctr" if (NULL != dptr) { if (0 != dk4app_pref_get(buf, DK4_SIZEOF(buf,dkChar), app, name, excl)) { endptr = NULL; val = (dk4_im_t)0L; back = dk4ma_input_dk_dec_dk4_im_t(&val, buf, &endptr, 1, NULL); if (0 != back) { *dptr = val; } if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { if ((NULL != app->msg_debug) && (43 < app->sz_msg_debug)) { dk4app_log_1( app, app->msg_debug, app->sz_msg_debug, DK4_LL_DEBUG, ((0 != back) ? 42 : 43) ); } } } } } #line 108 "dk4aprgs.ctr" return back; } int dk4app_pref_get_unsigned( dk4_um_t *dptr, dk4_app_t *app, const dkChar *name, int excl ) { dkChar buf[64]; const dkChar *endptr; dk4_um_t val; int back = 0; #line 126 "dk4aprgs.ctr" if (NULL != dptr) { if (0 != dk4app_pref_get(buf, DK4_SIZEOF(buf,dkChar), app, name, excl)) { endptr = NULL; val = (dk4_um_t)0UL; back = dk4ma_input_dk_dec_dk4_um_t(&val, buf, &endptr, 1, NULL); if (0 != back) { *dptr = val; } if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { if ((NULL != app->msg_debug) && (45 < app->sz_msg_debug)) { dk4app_log_1( app, app->msg_debug, app->sz_msg_debug, DK4_LL_DEBUG, ((0 != back) ? 44 : 45) ); } } } } } #line 145 "dk4aprgs.ctr" return back; } int dk4app_pref_get_bool( int *dptr, dk4_app_t *app, const dkChar *name, int excl ) { dkChar buf[64]; int back = 0; #line 161 "dk4aprgs.ctr" if (NULL != dptr) { if (0 != dk4app_pref_get(buf, DK4_SIZEOF(buf,dkChar), app, name, excl)) { if (0 != dk4str_is_bool(buf)) { if (0 != dk4str_is_on(buf)) { *dptr = 1; } else { *dptr = 0; } back = 1; } if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { if ((NULL != app->msg_debug) && (47 < app->sz_msg_debug)) { dk4app_log_1( app, app->msg_debug, app->sz_msg_debug, DK4_LL_DEBUG, ((0 != back) ? 46 : 47) ); } } } } } #line 183 "dk4aprgs.ctr" return back; } int dk4app_pref_get_size( size_t *dptr, dk4_app_t *app, const dkChar *name, int excl ) { dkChar buf[64]; const dkChar *endptr; size_t val; int back = 0; #line 201 "dk4aprgs.ctr" if (NULL != dptr) { if (0 != dk4app_pref_get(buf, DK4_SIZEOF(buf,dkChar), app, name, excl)) { endptr = NULL; val = 0; back = dk4ma_input_dk_dec_size_t(&val, buf, &endptr, 1, NULL); if (0 != back) { *dptr = val; } if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { if ((NULL != app->msg_debug) && (49 < app->sz_msg_debug)) { dk4app_log_1( app, app->msg_debug, app->sz_msg_debug, DK4_LL_DEBUG, ((0 != back) ? 48 : 49) ); } } } } } #line 219 "dk4aprgs.ctr" return back; } int dk4app_pref_set( dk4_app_t *app, const dkChar *name, const dkChar *value ) { dk4_pref_t *prefptr; dkChar *newval; int back = 0; #line 235 "dk4aprgs.ctr" if ((NULL != app) && (NULL != name) && (NULL != value)) { prefptr = dk4sto_it_find_like(app->i_pref_self, name, 1); if (NULL != prefptr) { newval = dk4str_dup(value, NULL); if (NULL != newval) { dk4mem_release(prefptr->value); prefptr->value = newval; back = 1; app->have_self_pref = 1; } } else { prefptr = dk4pref_open(name, value, NULL); if (NULL != prefptr) { if (dk4sto_add(app->s_pref_self, prefptr, NULL)) { back = 1; app->have_self_pref = 1; } else { dk4pref_close(prefptr); } } } } #line 257 "dk4aprgs.ctr" return back; } int dk4app_pref_set_int(dk4_app_t *app, const dkChar *name, dk4_im_t value) { dkChar buf[16*sizeof(dk4_im_t)]; int back = 0; #line 268 "dk4aprgs.ctr" if ((NULL != app) && (NULL != name)) { if (dk4ma_write_decimal_signed(buf,DK4_SIZEOF(buf,dkChar),value,0,NULL)) { back = dk4app_pref_set(app, name, buf); } } #line 273 "dk4aprgs.ctr" return back; } int dk4app_pref_set_unsigned(dk4_app_t *app, const dkChar *name, dk4_um_t value) { dkChar buf[16*sizeof(dk4_um_t)]; int back = 0; #line 284 "dk4aprgs.ctr" if ((NULL != app) && (NULL != name)) { if (dk4ma_write_decimal_unsigned(buf,DK4_SIZEOF(buf,dkChar),value,0,NULL)) { back = dk4app_pref_set(app, name, buf); } } #line 290 "dk4aprgs.ctr" return back; }