sanei_backend.h

Go to the documentation of this file.
00001 
00012 /*
00013  * Compiler related options
00014  */
00015 
00020 #ifdef __GNUC__
00021 #define __sane_unused__ __attribute__((unused))
00022 #else
00023 #define __sane_unused__
00024 #endif
00025 
00029 #include <sane/sanei_debug.h>
00030 
00031 #ifdef HAVE_SYS_HW_H
00032   /* OS/2 i/o-port access compatibility macros: */
00033 # define inb(p)         _inp8 (p)
00034 # define outb(v,p)      _outp8 ((p),(v))
00035 # define ioperm(b,l,o)  _portaccess ((b),(b)+(l)-1)
00036 # define HAVE_IOPERM    1
00037 #endif
00038 
00039 #ifndef HAVE_OS2_H
00040 #include <fcntl.h>
00041 #ifndef O_NONBLOCK
00042 # ifdef O_NDELAY
00043 #  define O_NONBLOCK O_NDELAY
00044 # else
00045 #  define O_NONBLOCK FNDELAY    /* last resort */
00046 # endif
00047 #endif
00048 #endif /* HAVE_OS2_H */
00049 
00050 #include <limits.h>
00051 #ifndef PATH_MAX
00052 # define PATH_MAX 1024
00053 #endif
00054 
00055 #ifdef HAVE_SIGPROCMASK
00056 # define SIGACTION      sigaction
00057 #else
00058 
00059 /* Just enough backwards compatibility that we get by in the backends
00060    without making handstands.  */
00061 # ifdef sigset_t
00062 #  undef sigset_t
00063 # endif
00064 # ifdef sigemptyset
00065 #  undef sigemptyset
00066 # endif
00067 # ifdef sigfillset
00068 #  undef sigfillset
00069 # endif
00070 # ifdef sigaddset
00071 #  undef sigaddset
00072 # endif
00073 # ifdef sigdelset
00074 #  undef sigdelset
00075 # endif
00076 # ifdef sigprocmask
00077 #  undef sigprocmask
00078 # endif
00079 # ifdef SIG_BLOCK
00080 #  undef SIG_BLOCK
00081 # endif
00082 # ifdef SIG_UNBLOCK
00083 #  undef SIG_UNBLOCK
00084 # endif
00085 # ifdef SIG_SETMASK
00086 #  undef SIG_SETMASK
00087 # endif
00088 
00089 # define sigset_t               int
00090 # define sigemptyset(set)       do { *(set) = 0; } while (0)
00091 # define sigfillset(set)        do { *(set) = ~0; } while (0)
00092 # define sigaddset(set,signal)  do { *(set) |= sigmask (signal); } while (0)
00093 # define sigdelset(set,signal)  do { *(set) &= ~sigmask (signal); } while (0)
00094 # define sigaction(sig,new,old) sigvec (sig,new,old)
00095 
00096   /* Note: it's not safe to just declare our own "struct sigaction" since
00097      some systems (e.g., some versions of OpenStep) declare that structure,
00098      but do not implement sigprocmask().  Hard to believe, aint it?  */
00099 # define SIGACTION              sigvec
00100 # define SIG_BLOCK      1
00101 # define SIG_UNBLOCK    2
00102 # define SIG_SETMASK    3
00103 #endif /* !HAVE_SIGPROCMASK */
00104 /* @} */
00105 
00106 
00110 extern SANE_Status ENTRY(init) (SANE_Int *, SANE_Auth_Callback);
00111 extern SANE_Status ENTRY(get_devices) (const SANE_Device ***, SANE_Bool);
00112 extern SANE_Status ENTRY(open) (SANE_String_Const, SANE_Handle *);
00113 extern const SANE_Option_Descriptor *
00114   ENTRY(get_option_descriptor) (SANE_Handle, SANE_Int);
00115 extern SANE_Status ENTRY(control_option) (SANE_Handle, SANE_Int, SANE_Action,
00116                                           void *, SANE_Word *);
00117 extern SANE_Status ENTRY(get_parameters) (SANE_Handle, SANE_Parameters *);
00118 extern SANE_Status ENTRY(start) (SANE_Handle);
00119 extern SANE_Status ENTRY(read) (SANE_Handle, SANE_Byte *, SANE_Int,
00120                                 SANE_Int *);
00121 extern SANE_Status ENTRY(set_io_mode) (SANE_Handle, SANE_Bool);
00122 extern SANE_Status ENTRY(get_select_fd) (SANE_Handle, SANE_Int *);
00123 extern void ENTRY(cancel) (SANE_Handle);
00124 extern void ENTRY(close) (SANE_Handle);
00125 extern void ENTRY(exit) (void);
00126 
00127 #ifndef STUBS
00128 /* Now redirect sane_* calls to backend's functions: */
00129 
00130 #define sane_init(a,b)                  ENTRY(init) (a,b)
00131 #define sane_get_devices(a,b)           ENTRY(get_devices) (a,b)
00132 #define sane_open(a,b)                  ENTRY(open) (a,b)
00133 #define sane_get_option_descriptor(a,b) ENTRY(get_option_descriptor) (a,b)
00134 #define sane_control_option(a,b,c,d,e)  ENTRY(control_option) (a,b,c,d,e)
00135 #define sane_get_parameters(a,b)        ENTRY(get_parameters) (a,b)
00136 #define sane_start(a)                   ENTRY(start) (a)
00137 #define sane_read(a,b,c,d)              ENTRY(read) (a,b,c,d)
00138 #define sane_set_io_mode(a,b)           ENTRY(set_io_mode) (a,b)
00139 #define sane_get_select_fd(a,b)         ENTRY(get_select_fd) (a,b)
00140 #define sane_cancel(a)                  ENTRY(cancel) (a)
00141 #define sane_close(a)                   ENTRY(close) (a)
00142 #define sane_exit(a)                    ENTRY(exit) (a)
00143 #endif /* STUBS */
00144 /* @} */
00145 
00151 #ifndef SANE_I18N
00152 #define SANE_I18N(text) text
00153 #endif
00154 
00159 #ifndef SANE_OPTION
00160 typedef union
00161 {
00162   SANE_Bool b;          
00163   SANE_Word w;          
00164   SANE_Word *wa;        
00165   SANE_String s;        
00166 }
00167 Option_Value;
00168 #define SANE_OPTION 1
00169 #endif

Generated on Wed Nov 5 02:30:50 2008 for SANEI by  doxygen 1.5.1