Tizen 2.1 base
[platform/upstream/hplip.git] / scan / sane / sanei.h
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.  If not, write to the Free
19    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 ../images/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 dcoumentation in the sanei_*.h
63  * files.
64  *
65  * This documenation is far from complete. Any help is appreciated.
66  *
67  * @section additional Additional documentation
68  * - The SANE standard can be found at <a 
69  *   href="http://www.sane-project.org/html/">the SANE webserver</a>.
70  * - Information on how to write a backend: <a
71  *   href="../backend-writing.txt">backend-writing.txt</a>.
72  * - General SANE documentation is on <a
73  *   href="http://www.sane-project.org/docs.html>the SANE documentation
74  *   page</a>.
75  * 
76  * @section contact Contact 
77  *
78  * The common way to contact the developers of SANE is the sane-devel
79  * mailing list. See the <a
80  * href="http://www.sane-project.org/mailing-lists.html">mailing list webpage</a>
81  * for details. That's the place to ask questions, report bugs, or announce
82  * a new backend.
83  * 
84  */
85
86 #ifndef sanei_h
87 #define sanei_h
88
89 #include "sane.h"
90
91 /** @name Public macros and functions
92  * @{
93  */
94 /** @def STRINGIFY(x)
95  * Turn parameter into string.
96  */
97 /** @def PASTE(x,y)
98  * Concatenate parameters.
99  *
100  */
101 /** @def NELEMS(a)
102  * Return number of elements of an array.
103  *
104  */
105
106 /** @fn extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, void * value);
107  * Check the constraints of a SANE option.
108  *
109  * @param opt   option to check
110  * @param value value of the option
111  *
112  * @return 
113  * - SANE_STATUS_GOOD     - on success
114  * - SANE_STATUS_INVAL    - if the value doesn't fit inside the constraint
115  *   or any other error occured
116  * @sa sanei_constrain_value()
117  */
118
119 /** @fn extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value, SANE_Word * info);
120  * Check the constraints of a SANE option and adjust its value if necessary.
121  *
122  * Depending on the type of the option and constraint, value is modified
123  * to fit inside constraint.
124  *
125  * @param opt   option to check
126  * @param value value of the option
127  * @param info  info is set to SANE_INFO_INEXACT if value was changed
128  *
129  * @return 
130  * - SANE_STATUS_GOOD     - on success
131  * - SANE_STATUS_INVAL    - if the function wasn't able to fit value into the
132  *   constraint or any other error occured
133  * @sa sanei_check_value()
134  */
135
136 /* @} */
137
138 /** @name Private macros
139  * @{
140  */
141 /** @def STRINGIFY1(x)
142  * Internal use only.
143  */
144 /** @def PASTE1(x,y)
145  * Internal use only.
146  */
147 /* @} */
148
149 /* A few convenience macros:  */
150 /** @hideinitializer */
151 #define NELEMS(a)       ((int)(sizeof (a) / sizeof (a[0])))
152
153 /** @hideinitializer */
154 #define STRINGIFY1(x)   #x
155 /** @hideinitializer */
156 #define STRINGIFY(x)    STRINGIFY1(x)
157
158 /** @hideinitializer */
159 #define PASTE1(x,y)     x##y
160 /** @hideinitializer */
161 #define PASTE(x,y)      PASTE1(x,y)
162
163 extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt,
164                                       void * value);
165
166 extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt,
167                                           void * value, SANE_Word * info);
168
169
170 #endif /* sanei_h */