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