SANEI 1.3.1.72-4c77c
sanei_backend.h
Go to the documentation of this file.
1
15#include <sane/sanei_debug.h>
16
17#if __STDC_VERSION__ >= 199901L
18/* __func__ is provided */
19#elif __GNUC__ >= 5
20/* __func__ is provided */
21#elif __GNUC__ >= 2
22# define __func__ __FUNCTION__
23#else
24# define __func__ "(unknown)"
25#endif
26
27#ifndef HAVE_OS2_H
28#include <fcntl.h>
29#ifndef O_NONBLOCK
30# ifdef O_NDELAY
31# define O_NONBLOCK O_NDELAY
32# else
33# ifdef FNDELAY
34# define O_NONBLOCK FNDELAY /* last resort */
35# endif
36# endif
37#endif
38#endif /* HAVE_OS2_H */
39
40#include <limits.h>
41#ifndef PATH_MAX
42# define PATH_MAX 1024
43#endif
44
45#ifndef M_PI
46#define M_PI 3.14159265358979323846
47#endif
48
49#ifndef MM_PER_INCH
50#define MM_PER_INCH 25.4
51#endif
52
53#ifdef HAVE_SIGPROCMASK
54# define SIGACTION sigaction
55#else
56
57/* Just enough backwards compatibility that we get by in the backends
58 without making handstands. */
59# ifdef sigset_t
60# undef sigset_t
61# endif
62# ifdef sigemptyset
63# undef sigemptyset
64# endif
65# ifdef sigfillset
66# undef sigfillset
67# endif
68# ifdef sigaddset
69# undef sigaddset
70# endif
71# ifdef sigdelset
72# undef sigdelset
73# endif
74# ifdef sigprocmask
75# undef sigprocmask
76# endif
77# ifdef SIG_BLOCK
78# undef SIG_BLOCK
79# endif
80# ifdef SIG_UNBLOCK
81# undef SIG_UNBLOCK
82# endif
83# ifdef SIG_SETMASK
84# undef SIG_SETMASK
85# endif
86
87# define sigset_t int
88# define sigemptyset(set) do { *(set) = 0; } while (0)
89# define sigfillset(set) do { *(set) = ~0; } while (0)
90# define sigaddset(set,signal) do { *(set) |= sigmask (signal); } while (0)
91# define sigdelset(set,signal) do { *(set) &= ~sigmask (signal); } while (0)
92# define sigaction(sig,new,old) sigvec (sig,new,old)
93
94 /* Note: it's not safe to just declare our own "struct sigaction" since
95 some systems (e.g., some versions of OpenStep) declare that structure,
96 but do not implement sigprocmask(). Hard to believe, aint it? */
97# define SIGACTION sigvec
98# define SIG_BLOCK 1
99# define SIG_UNBLOCK 2
100# define SIG_SETMASK 3
101#endif /* !HAVE_SIGPROCMASK */
102/* @} */
103
104
108#ifdef __cplusplus
109extern "C" {
110#endif
111
112extern SANE_Status ENTRY(init) (SANE_Int *, SANE_Auth_Callback);
113extern SANE_Status ENTRY(get_devices) (const SANE_Device ***, SANE_Bool);
114extern SANE_Status ENTRY(open) (SANE_String_Const, SANE_Handle *);
115extern const SANE_Option_Descriptor *
116 ENTRY(get_option_descriptor) (SANE_Handle, SANE_Int);
117extern SANE_Status ENTRY(control_option) (SANE_Handle, SANE_Int, SANE_Action,
118 void *, SANE_Word *);
119extern SANE_Status ENTRY(get_parameters) (SANE_Handle, SANE_Parameters *);
120extern SANE_Status ENTRY(start) (SANE_Handle);
121extern SANE_Status ENTRY(read) (SANE_Handle, SANE_Byte *, SANE_Int,
122 SANE_Int *);
123extern SANE_Status ENTRY(set_io_mode) (SANE_Handle, SANE_Bool);
124extern SANE_Status ENTRY(get_select_fd) (SANE_Handle, SANE_Int *);
125extern void ENTRY(cancel) (SANE_Handle);
126extern void ENTRY(close) (SANE_Handle);
127extern void ENTRY(exit) (void);
128
129#ifdef __cplusplus
130} // extern "C"
131#endif
132
133#ifndef STUBS
134/* Now redirect sane_* calls to backend's functions: */
135
136#define sane_init(a,b) ENTRY(init) (a,b)
137#define sane_get_devices(a,b) ENTRY(get_devices) (a,b)
138#define sane_open(a,b) ENTRY(open) (a,b)
139#define sane_get_option_descriptor(a,b) ENTRY(get_option_descriptor) (a,b)
140#define sane_control_option(a,b,c,d,e) ENTRY(control_option) (a,b,c,d,e)
141#define sane_get_parameters(a,b) ENTRY(get_parameters) (a,b)
142#define sane_start(a) ENTRY(start) (a)
143#define sane_read(a,b,c,d) ENTRY(read) (a,b,c,d)
144#define sane_set_io_mode(a,b) ENTRY(set_io_mode) (a,b)
145#define sane_get_select_fd(a,b) ENTRY(get_select_fd) (a,b)
146#define sane_cancel(a) ENTRY(cancel) (a)
147#define sane_close(a) ENTRY(close) (a)
148#define sane_exit(a) ENTRY(exit) (a)
149#endif /* STUBS */
150/* @} */
151
157#ifndef SANE_I18N
158#define SANE_I18N(text) text
159#endif
160
165#ifndef SANE_OPTION
166typedef union
167{
168 SANE_Bool b;
169 SANE_Word w;
170 SANE_Word *wa;
171 SANE_String s;
172}
174#define SANE_OPTION 1
175#endif
SANE_Status ENTRY() open(SANE_String_Const, SANE_Handle *)
Internationalization for SANE backends.
void ENTRY() exit(void)
Internationalization for SANE backends.
SANE_Status ENTRY() set_io_mode(SANE_Handle, SANE_Bool)
Internationalization for SANE backends.
SANE_Status ENTRY() get_parameters(SANE_Handle, SANE_Parameters *)
Internationalization for SANE backends.
const SANE_Option_Descriptor *ENTRY() get_option_descriptor(SANE_Handle, SANE_Int)
Internationalization for SANE backends.
void ENTRY() cancel(SANE_Handle)
Internationalization for SANE backends.
SANE_Status ENTRY() init(SANE_Int *, SANE_Auth_Callback)
Internationalization for SANE backends.
SANE_Status ENTRY() get_select_fd(SANE_Handle, SANE_Int *)
Internationalization for SANE backends.
void ENTRY() close(SANE_Handle)
Internationalization for SANE backends.
SANE_Status ENTRY() control_option(SANE_Handle, SANE_Int, SANE_Action, void *, SANE_Word *)
Internationalization for SANE backends.
SANE_Status ENTRY() read(SANE_Handle, SANE_Byte *, SANE_Int, SANE_Int *)
Internationalization for SANE backends.
SANE_Status ENTRY() get_devices(const SANE_Device ***, SANE_Bool)
Internationalization for SANE backends.
SANE_Status ENTRY() start(SANE_Handle)
Internationalization for SANE backends.
Support for printing debug messages.
#define ENTRY(name)
Expands to sane_BACKEND_NAME_name.
Definition: sanei_debug.h:74
Option_Value union.
Definition: sanei_backend.h:167
SANE_Word w
word
Definition: sanei_backend.h:169
SANE_Word * wa
word array
Definition: sanei_backend.h:170
SANE_String s
string
Definition: sanei_backend.h:171
SANE_Bool b
bool
Definition: sanei_backend.h:168