1 /* sane - Scanner Access Now Easy. 2 Copyright (C) 1996 David Mosberger-Tang and Andreas Beck 3 Copyright (C) 2002, 2003 Henning Meier-Geinitz 4 5 This file is part of the SANE package. 6 7 SANE is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 SANE is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with sane; see the file COPYING. 19 If not, see <https://www.gnu.org/licenses/>. 20 21 As a special exception, the authors of SANE give permission for 22 additional uses of the libraries contained in this release of SANE. 23 24 The exception is that, if you link a SANE library with other files 25 to produce an executable, this does not by itself cause the 26 resulting executable to be covered by the GNU General Public 27 License. Your use of that executable is in no way restricted on 28 account of linking the SANE library code into it. 29 30 This exception does not, however, invalidate any other reasons why 31 the executable file might be covered by the GNU General Public 32 License. 33 34 If you submit changes to SANE to the maintainers to be included in 35 a subsequent release, you agree by submitting the changes that 36 those changes may be distributed with this exception intact. 37 38 If you write modifications of your own for SANE, it is your choice 39 whether to permit this exception to apply to your modifications. 40 If you do not wish that, delete this exception notice. 41 */ 42 43 /** @file sanei.h 44 * Convenience macros and function declarations for backends 45 * @sa sanei_backend.h sanei_thread.h 46 */ 47 48 /* Doxygen documentation */ 49 50 /** @mainpage SANEI (SANE internal routines) documentation 51 * 52 * @image html sane-logo2.jpg 53 * @section intro Introduction 54 * 55 * The header files in the include/sane/ directory named sanei_*.h provide 56 * function declarations and macros that can be used by every SANE backend. 57 * Their implementations can be found in the sanei/ directory. The code aims 58 * to be platform-independent to avoid lots of \#ifdef code in the backends. 59 * Please use the SANEI functions wherever possible. 60 * 61 * This documentation was created by the use of doxygen, the 62 * doc/doxygen-sanei.conf configuration file and documentation in the sanei_*.h 63 * files. 64 * 65 * This documentation is far from complete. Any help is appreciated. 66 * 67 * @section additional Additional documentation 68 * - The <a href="https://sane-project.gitlab.io/standard/">SANE Standard</a>. 69 * - Information on how to write a backend: <a 70 * href="../backend-writing.txt">backend-writing.txt</a>. 71 * - General SANE documentation is on <a 72 * href="http://www.sane-project.org/docs.html">the SANE documentation 73 * page</a>. 74 * 75 * @section contact Contact 76 * 77 * The common way to contact the developers of SANE is the sane-devel 78 * mailing list. See the <a 79 * href="http://www.sane-project.org/mailing-lists.html">mailing list webpage</a> 80 * for details. That's the place to ask questions, report bugs, or announce 81 * a new backend. 82 * 83 */ 84 85 #ifndef sanei_h 86 #define sanei_h 87 88 #include <sane/sane.h> 89 90 #ifdef __cplusplus 91 extern "C" { 92 #endif 93 94 /** @name Public macros and functions 95 * @{ 96 */ 97 /** @def __sane_unused__ 98 * Mark parameters as potentially unused. 99 */ 100 /** @def STRINGIFY(x) 101 * Turn parameter into string. 102 */ 103 /** @def PASTE(x,y) 104 * Concatenate parameters. 105 * 106 */ 107 /** @def NELEMS(a) 108 * Return number of elements of an array. 109 * 110 */ 111 112 /** @fn extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, void * value); 113 * Check the constraints of a SANE option. 114 * 115 * @param opt option to check 116 * @param value value of the option 117 * 118 * @return 119 * - SANE_STATUS_GOOD - on success 120 * - SANE_STATUS_INVAL - if the value doesn't fit inside the constraint 121 * or any other error occurred 122 * @sa sanei_constrain_value() 123 */ 124 125 /** @fn extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value, SANE_Word * info); 126 * Check the constraints of a SANE option and adjust its value if necessary. 127 * 128 * Depending on the type of the option and constraint, value is modified 129 * to fit inside constraint. 130 * 131 * @param opt option to check 132 * @param value value of the option 133 * @param info info is set to SANE_INFO_INEXACT if value was changed 134 * 135 * @return 136 * - SANE_STATUS_GOOD - on success 137 * - SANE_STATUS_INVAL - if the function wasn't able to fit value into the 138 * constraint or any other error occurred 139 * @sa sanei_check_value() 140 */ 141 142 /* @} */ 143 144 /* A few convenience macros: */ 145 146 /** @hideinitializer */ 147 #ifdef __GNUC__ 148 #define __sane_unused__ __attribute__((unused)) 149 #else 150 #define __sane_unused__ 151 #endif 152 153 /** @hideinitializer */ 154 #define NELEMS(a) ((int)(sizeof (a) / sizeof (a[0]))) 155 156 /** @hideinitializer */ 157 #define STRINGIFY1(x) #x 158 /** @hideinitializer */ 159 #define STRINGIFY(x) STRINGIFY1(x) 160 161 /** @hideinitializer */ 162 #define PASTE1(x,y) x##y 163 /** @hideinitializer */ 164 #define PASTE(x,y) PASTE1(x,y) 165 166 extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, 167 void * value); 168 169 extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, 170 void * value, SANE_Word * info); 171 172 #ifdef __cplusplus 173 } // extern "C" 174 #endif 175 176 #endif /* sanei_h */ 177