From 7d8191b83e163d76bb05e13b373638e4eeb7da95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Tue, 2 Dec 2014 20:17:04 +0100 Subject: Initial import of sane-frontends version 1.0.14-9 --- include/sane/config.h.in | 219 +++++++++++++++++++++++++++++++++++++++ include/sane/sanei.h | 173 +++++++++++++++++++++++++++++++ include/sane/sanei_codec_ascii.h | 62 +++++++++++ include/sane/sanei_codec_bin.h | 61 +++++++++++ include/sane/sanei_debug.h | 176 +++++++++++++++++++++++++++++++ include/sane/sanei_wire.h | 132 +++++++++++++++++++++++ 6 files changed, 823 insertions(+) create mode 100644 include/sane/config.h.in create mode 100644 include/sane/sanei.h create mode 100644 include/sane/sanei_codec_ascii.h create mode 100644 include/sane/sanei_codec_bin.h create mode 100644 include/sane/sanei_debug.h create mode 100644 include/sane/sanei_wire.h (limited to 'include/sane') diff --git a/include/sane/config.h.in b/include/sane/config.h.in new file mode 100644 index 0000000..baf35be --- /dev/null +++ b/include/sane/config.h.in @@ -0,0 +1,219 @@ +/* include/sane/config.h.in. Generated from configure.in by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if GIMP 1.2 support wanted */ +#undef ENABLE_GIMP_1_2 + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `getenv' function. */ +#undef HAVE_GETENV + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `isfdtype' function. */ +#undef HAVE_ISFDTYPE + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBGIMP_GIMPFEATURES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBGIMP_GIMP_H + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the `syslog' library (-lsyslog). */ +#undef HAVE_LIBSYSLOG + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `mkdir' function. */ +#undef HAVE_MKDIR + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_OS2_H + +/* Define to 1 if you have the `sigprocmask' function. */ +#undef HAVE_SIGPROCMASK + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strndup' function. */ +#undef HAVE_STRNDUP + +/* Define to 1 if you have the `strsep' function. */ +#undef HAVE_STRSEP + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the `strtod' function. */ +#undef HAVE_STRTOD + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + +/* Define to 1 if you have the `vsyslog' function. */ +#undef HAVE_VSYSLOG + +/* Define to the name of the distribution. */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the name and the version of the distribution. */ +#undef PACKAGE_VERSION + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to the version of the distribution. */ +#undef VERSION + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define as `__inline' if that's what the C compiler calls it, or to nothing + if it is not supported. */ +#undef inline + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to `unsigned' if does not define. */ +#undef size_t + +/* Define to `long' if does not define. */ +#undef ssize_t + +/* Define for OS/2 only */ +#undef strcasecmp + +/* Define for OS/2 only */ +#undef strncasecmp + +/* Define to `unsigned char' if does not define. */ +#undef u_char + +/* Define to `unsigned int' if does not define. */ +#undef u_int + +/* Define to `unsigned short' if does not define. */ +#undef u_int16_t + +/* Define to `unsigned int' if does not define. */ +#undef u_int32_t + +/* Define to `unsigned char' if does not define. */ +#undef u_int8_t + +/* Define to `unsigned long' if does not define. */ +#undef u_long diff --git a/include/sane/sanei.h b/include/sane/sanei.h new file mode 100644 index 0000000..d736b17 --- /dev/null +++ b/include/sane/sanei.h @@ -0,0 +1,173 @@ +/* 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 ../images/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 dcoumentation in the sanei_*.h + * files. + * + * This documenation is far from complete. Any help is appreciated. + * + * @section additional Additional documentation + * - The SANE standard can be found at the SANE webserver. + * - Information on how to write a backend: backend-writing.txt. + * - General SANE documentation is on mailing list webpage + * for details. That's the place to ask questions, report bugs, or announce + * a new backend. + * + */ + +#ifndef sanei_h +#define sanei_h + +#include + +/** @name Public macros and functions + * @{ + */ +/** @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() + */ + +/* @} */ + +/** @name Private macros + * @{ + */ +/** @def STRINGIFY1(x) + * Internal use only. + */ +/** @def PASTE1(x,y) + * Internal use only. + */ +/* @} */ + +/* A few convenience macros: */ +/** @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); + + +extern int sanei_save_values (int fd, SANE_Handle device); +extern int sanei_load_values (int fd, SANE_Handle device); + +#endif /* sanei_h */ diff --git a/include/sane/sanei_codec_ascii.h b/include/sane/sanei_codec_ascii.h new file mode 100644 index 0000000..991499a --- /dev/null +++ b/include/sane/sanei_codec_ascii.h @@ -0,0 +1,62 @@ +/* sane - Scanner Access Now Easy. + Copyright (C) 1996 David Mosberger-Tang and Andreas Beck + 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_codec_ascii.h + * ASCII codec for network and file transmissions + * + * Instead translating data to a byte stream this codec uses ASCII hex numbers. + * Therefore it can be used for streams that are not 8-bit clean or which can + * only use printable characters. It's currently used for saving/restoring + * data to/from disk. + * + * @sa sanei_codec_bin.h sanei_net.h sanei_wire.h + */ +#ifndef sanei_codec_ascii_h +#define sanei_codec_ascii_h + +/** Initialize the ascii codec + * + * Set the i/o functions of the Wire to those of the ASCII codec. + * + * @param w Wire + */ +extern void sanei_codec_ascii_init (Wire *w); + +#endif /* sanei_codec_ascii_h */ diff --git a/include/sane/sanei_codec_bin.h b/include/sane/sanei_codec_bin.h new file mode 100644 index 0000000..ba17bac --- /dev/null +++ b/include/sane/sanei_codec_bin.h @@ -0,0 +1,61 @@ +/* sane - Scanner Access Now Easy. + Copyright (C) 1996 David Mosberger-Tang and Andreas Beck + 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_codec_bin.h + * Binary codec for network transmissions + * + * Transtale data to a byte stream while taking byte order problems into + * account. This codec is currently used for saned and the network backend. + * + * @sa sanei_codec_ascii.h sanei_net.h sanei_wire.h + */ + +#ifndef sanei_codec_bin_h +#define sanei_codec_bin_h + +/** Initialize the binary codec + * + * Set the i/o functions of the Wire to those of the binary codec. + * + * @param w Wire + */ +extern void sanei_codec_bin_init (Wire *w); + +#endif /* sanei_codec_bin_h */ diff --git a/include/sane/sanei_debug.h b/include/sane/sanei_debug.h new file mode 100644 index 0000000..5cf2e45 --- /dev/null +++ b/include/sane/sanei_debug.h @@ -0,0 +1,176 @@ +/** @file sanei_debug.h + * Support for printing debug messages. + * + * Use the functions of this header file to print debug or warning messages. + */ + +#ifndef _SANEI_DEBUG_H +#define _SANEI_DEBUG_H + +#include + +/** @name Public macros + * These macros can be used in backends and other SANE-related + * code. + * + * Before including sanei_debug.h, the following macros must be set: + * + * - BACKEND_NAME - The name of your backend without double-quotes (must be set in any case) + * - STUBS - If this is defined, no macros will be included. Used in + * backends consisting of more than one .c file. + * - DEBUG_DECLARE_ONLY - Generates prototypes instead of functions. Used in + * backends consisting of more than one .c file. + * - DEBUG_NOT_STATIC - Doesn't generate static functions. Used in header files if + * they are include in more than one .c file. + * + * @{ + */ + +/** @def DBG_INIT() + * Initialize sanei_debug. + * + * Call this function before you use any DBG function. + */ + +/** @def DBG(level, fmt, ...) + * Print a message at debug level `level' or higher using a printf-like + * function. Example: DBG(1, "sane_open: opening fd \%d\\n", fd). + * + * @param level debug level + * @param fmt format (see man 3 printf for details) + * @param ... additional arguments + */ + +/** @def IF_DBG(x) + * Compile code only if debugging is enabled. + * + * Expands to x if debug support is enabled at compile-time. If NDEBUG is + * defined at compile-time this macro expands to nothing. + * + * @param x code to expand when debugging is enabled + */ + +/** + * @def DBG_LEVEL + * Current debug level. + * + * You can only read this "variable". + */ + +/** @def ENTRY(name) + * Expands to sane_BACKEND_NAME_name. + * + * Example: ENTRY(init) in mustek.c will expand to sane_mustek_init. + */ + +/* @} */ + +/** @name Internal macros and functions + * Do not use in your own code. + * @{ + */ + +/** @def DBG_LOCAL + * Do not use in backends directly. + * + * Internal wrapper for printing function. + */ + +/** @fn extern void sanei_init_debug (const char * backend, int * debug_level_var); + * Do not use in backends directly. + * + * Actual init function. + */ + +/** @fn extern void sanei_debug_msg (int level, int max_level, const char *be, const char *fmt, va_list ap); + * Do not use in backends directly. + * + * Actual printing function. + */ +/* @} */ + + /** @hideinitializer*/ +#define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name) + +#ifdef NDEBUG + +extern void sanei_debug_ndebug (int level, const char *msg, ...); + +# define DBG_LEVEL (0) +# define DBG_INIT() +# define DBG sanei_debug_ndebug +# define IF_DBG(x) + +#else /* !NDEBUG */ + + /** @hideinitializer*/ +# define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME) + +# if defined(BACKEND_NAME) && !defined(STUBS) +# ifdef DEBUG_DECLARE_ONLY +extern int DBG_LEVEL; +# else /* !DEBUG_DECLARE_ONLY */ +int DBG_LEVEL = 0; +# endif /* DEBUG_DECLARE_ONLY */ +# endif /* BACKEND_NAME && !STUBS */ + + /** @hideinitializer*/ +# define DBG_INIT() \ + sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL) + + /** @hideinitializer*/ +# define DBG_LOCAL PASTE(DBG_LEVEL,_call) + + +# ifndef STUBS + +# ifdef DEBUG_DECLARE_ONLY + +extern void DBG_LOCAL (int level, const char *msg, ...) +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +; + +# else /* !DEBUG_DECLARE_ONLY */ + +# include + +extern void sanei_debug_msg + (int level, int max_level, const char *be, const char *fmt, va_list ap); + +#ifdef __GNUC__ +# ifndef DEBUG_NOT_STATIC +static +# endif /* !DEBUG_NOT_STATIC */ +void DBG_LOCAL (int level, const char *msg, ...) __attribute__ ((format (printf, 2, 3))); +#endif /* __GNUC__ */ + +# ifndef DEBUG_NOT_STATIC +static +# endif /* !DEBUG_NOT_STATIC */ +void +DBG_LOCAL (int level, const char *msg, ...) +{ + va_list ap; + + va_start (ap, msg); + sanei_debug_msg (level, DBG_LEVEL, STRINGIFY(BACKEND_NAME), msg, ap); + va_end (ap); +} + +# endif /* DEBUG_DECLARE_ONLY */ + +# endif /* !STUBS */ + + /** @hideinitializer*/ +# define DBG DBG_LOCAL + +extern void sanei_init_debug (const char * backend, int * debug_level_var); + + /** @hideinitializer*/ +# define IF_DBG(x) x + +#endif /* NDEBUG */ + +#endif /* _SANEI_DEBUG_H */ diff --git a/include/sane/sanei_wire.h b/include/sane/sanei_wire.h new file mode 100644 index 0000000..95be5cf --- /dev/null +++ b/include/sane/sanei_wire.h @@ -0,0 +1,132 @@ +/* sane - Scanner Access Now Easy. + Copyright (C) 1997 David Mosberger-Tang + 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. + + Support routines to translate internal datatypes into a wire-format + (used for RPCs and to save/restore options). */ + +#ifndef sanei_wire_h +#define sanei_wire_h + +#include + +#define MAX_MEM (1024 * 1024) + +typedef enum + { + WIRE_ENCODE = 0, + WIRE_DECODE, + WIRE_FREE + } +WireDirection; + +struct Wire; + +typedef void (*WireCodecFunc) (struct Wire *w, void *val_ptr); +typedef ssize_t (*WireReadFunc) (int fd, void * buf, size_t len); +typedef ssize_t (*WireWriteFunc) (int fd, const void * buf, size_t len); + +typedef struct Wire + { + int version; /* protocol version in use */ + WireDirection direction; + int status; + int allocated_memory; + struct + { + WireCodecFunc w_byte; + WireCodecFunc w_char; + WireCodecFunc w_word; + WireCodecFunc w_string; + } + codec; + struct + { + size_t size; + char *curr; + char *start; + char *end; + } + buffer; + struct + { + int fd; + WireReadFunc read; + WireWriteFunc write; + } + io; + } +Wire; + +extern void sanei_w_init (Wire *w, void (*codec_init)(Wire *)); +extern void sanei_w_exit (Wire *w); +extern void sanei_w_space (Wire *w, size_t howmuch); +extern void sanei_w_void (Wire *w); +extern void sanei_w_byte (Wire *w, SANE_Byte *v); +extern void sanei_w_char (Wire *w, SANE_Char *v); +extern void sanei_w_word (Wire *w, SANE_Word *v); +extern void sanei_w_bool (Wire *w, SANE_Bool *v); +extern void sanei_w_ptr (Wire *w, void **v, WireCodecFunc w_value, + size_t value_size); +extern void sanei_w_string (Wire *w, SANE_String *v); +extern void sanei_w_status (Wire *w, SANE_Status *v); +extern void sanei_w_constraint_type (Wire *w, SANE_Constraint_Type *v); +extern void sanei_w_value_type (Wire *w, SANE_Value_Type *v); +extern void sanei_w_unit (Wire *w, SANE_Unit *v); +extern void sanei_w_action (Wire *w, SANE_Action *v); +extern void sanei_w_frame (Wire *w, SANE_Frame *v); +extern void sanei_w_range (Wire *w, SANE_Range *v); +extern void sanei_w_range_ptr (Wire *w, SANE_Range **v); +extern void sanei_w_device (Wire *w, SANE_Device *v); +extern void sanei_w_device_ptr (Wire *w, SANE_Device **v); +extern void sanei_w_option_descriptor (Wire *w, SANE_Option_Descriptor *v); +extern void sanei_w_option_descriptor_ptr (Wire *w, + SANE_Option_Descriptor **v); +extern void sanei_w_parameters (Wire *w, SANE_Parameters *v); + +extern void sanei_w_array (Wire *w, SANE_Word *len, void **v, + WireCodecFunc w_element, size_t element_size); + +extern void sanei_w_set_dir (Wire *w, WireDirection dir); +extern void sanei_w_call (Wire *w, SANE_Word proc_num, + WireCodecFunc w_arg, void *arg, + WireCodecFunc w_reply, void *reply); +extern void sanei_w_reply (Wire *w, WireCodecFunc w_reply, void *reply); +extern void sanei_w_free (Wire *w, WireCodecFunc w_reply, void *reply); + +#endif /* sanei_wire_h */ -- cgit v1.2.3