/* 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: dk4aopt.ctr */ /* Copyright (C) 2014, 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. */ #ifndef DK4AOPT_H_INCLUDED /** Avoid multiple inclusions. */ #define DK4AOPT_H_INCLUDED 1 /** @file dk4aopt.h Command line options with dk4_app_t support. The dk4app_opt_is_set_short() and dk4app_opt_is_set_long() only return success, if the specified option was allowed in the option specification and found on the command line. The dk4app_opt_get_string_short(), dk4app_opt_get_string_long(), dk4app_opt_get_double_short(), dk4app_opt_get_double_long(), dk4app_opt_get_int_short(), dk4app_opt_get_int_long(), dk4app_opt_get_unsigned_short(), dk4app_opt_get_unsigned_long(), dk4app_opt_get_size_short(), dk4app_opt_get_size_long(), dk4app_opt_get_bool_short(), and dk4app_opt_get_bool_long() functions only return success, if the specified option was allowed/configured in the option specifications with the correct data type and the option was found on the command line. */ #ifndef DK4CONF_H_INCLUDED #include "dk4conf.h" #endif #ifndef DK4TYPES_H_INCLUDED #include "dk4types.h" #endif #ifndef DK4ERROR_H_INCLUDED #include "dk4error.h" #endif #ifndef DK4APP_H_INCLUDED #include "dk4app.h" #endif #ifndef DK4OPT_H_INCLUDED #include "dk4opt.h" #endif #ifdef __cplusplus extern "C" { #endif /** Check whether a short option is set. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 if option is set, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_is_set_short(dk4_app_t *app, dkChar c, dk4_er_t *erp); /** Check whether a long option is set. @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 if option is set, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp, app, or n is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_is_set_long(dk4_app_t *app, const dkChar *n, dk4_er_t *erp); /** Get string argument for short option. @param dptr Address of result buffer. @param szdptr Size of result buffer (number of dkChar). @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type, - DK4_E_BUFFER_TOO_SMALL
if the destination buffer is too small to hold the text, - DK4_E_BUFFER_TOO_SMALL
if the destination buffer is too small to hold a conversion result, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_string_short( dkChar *dptr, size_t szdptr, dk4_app_t *app, dkChar c, dk4_er_t *erp ); /** Get string argument for long option. @param dptr Address of result buffer. @param szdptr Size of result buffer (number of dkChar). @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type, - DK4_E_BUFFER_TOO_SMALL
if the destination buffer is too small to hold the text, - DK4_E_BUFFER_TOO_SMALL
if the destination buffer is too small to hold a conversion result, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_string_long( dkChar *dptr, size_t szdptr, dk4_app_t *app, const dkChar *n, dk4_er_t *erp ); /** Get pointer to string argument for short option. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return Pointer to string argument on success, NULL on error. Error codes: - DK4_E_INVALID_ARGUMENTS
if app is NULL or there is no option storage in app, - DK4_E_SYNTAX
if c is not in the list of accepted options or does not accept a string argument, - DK4_E_NOT_FOUND
if the option was not specified on the command line. */ const dkChar * dk4app_opt_get_string_ptr_short(dk4_app_t *app, dkChar c, dk4_er_t *erp); /** Get pointer to string argument for long option. @param app Application structure. @param n Long option character. @param erp Error report, may be NULL. @return Pointer to string argument on success, NULL on error. Error codes: - DK4_E_INVALID_ARGUMENTS
if app is NULL or there is no option storage in app, - DK4_E_SYNTAX
if n is not in the list of accepted options or does not accept a string argument, - DK4_E_NOT_FOUND
if the option was not specified on the command line. */ const dkChar * dk4app_opt_get_string_ptr_long(dk4_app_t *app, const dkChar *n, dk4_er_t *erp); /** Get double argument for short option. @param rp Address of result variable. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_double_short( double *rp, dk4_app_t *app, dkChar c, dk4_er_t *erp ); /** Get double argument for long option. @param rp Address of result variable. @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp, app, or n is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_double_long( double *rp, dk4_app_t *app, const dkChar *n, dk4_er_t *erp ); /** Get integer argument for short option. @param rp Address of result variable. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible type or the option argument string does not represent an integer number, - DK4_E_MATH_OVERFLOW
if the option was configured for another numeric type and conversion results in an overflow, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_int_short(dk4_im_t *rp, dk4_app_t *app, dkChar c, dk4_er_t *erp); /** Get integer argument for long option. @param rp Address of result variable. @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible type or the option argument string does not represent an integer number, - DK4_E_MATH_OVERFLOW
if the option was configured for another numeric type and conversion results in an overflow, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_int_long( dk4_im_t *rp, dk4_app_t *app, const dkChar *n, dk4_er_t *erp ); /** Get unsigned integer argument for short option. @param rp Address of result variable. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type or the option argument string does not represent an integer number, - DK4_E_MATH_OVERFLOW
if the option was configured for an incompatible numeric type and a negative value is stored, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_unsigned_short( dk4_um_t *rp, dk4_app_t *app, dkChar c, dk4_er_t *erp ); /** Get unsigned integer argument for long option. @param rp Address of result variable. @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type or the option argument string does not represent an integer number, - DK4_E_MATH_OVERFLOW
if the option was configured for an incompatible numeric type and a negative value is stored, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_unsigned_long( dk4_um_t *rp, dk4_app_t *app, const dkChar *n, dk4_er_t *erp ); /** Get size_t argument for short option. @param rp Address of result variable. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible type or the option argument string can not be converted to size_t, - DK4_E_MATH_OVERFLOW
if the option was configured for another numeric type and conversion results in an overflow. - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_size_short(size_t *rp, dk4_app_t *app, dkChar c, dk4_er_t *erp); /** Get size_t argument for long option. @param rp Address of result variable. @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp or app is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible type or the option argument string can not be converted to size_t, - DK4_E_MATH_OVERFLOW
if the option was configured for another numeric type and conversion results in an overflow. - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_size_long( size_t *rp, dk4_app_t *app, const dkChar *n, dk4_er_t *erp ); /** Get boolean argument for short option. @param rp Address of result variable. @param app Application structure. @param c Short option character. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp, app, or n is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_bool_short(int *rp, dk4_app_t *app, dkChar c, dk4_er_t *erp); /** Get boolean argument for long option. @param rp Address of result variable. @param app Application structure. @param n Long option name. @param erp Error report, may be NULL. @return 1 on success, 0 otherwise. Error codes: - DK4_E_INVALID_ARGUMENTS
if rp, app, or n is NULL or the application is not configured for preferences retrieval, - DK4_E_SYNTAX
if an invalid option was specified or the option was configured for an incompatible data type, - DK4_E_NOT_FOUND
if the option was not used on the command line. */ int dk4app_opt_get_bool_long( int *rp, dk4_app_t *app, const dkChar *n, dk4_er_t *erp ); #ifdef __cplusplus } #endif #endif