sanei_wire.h

00001 /* sane - Scanner Access Now Easy.
00002    Copyright (C) 1997 David Mosberger-Tang
00003    This file is part of the SANE package.
00004 
00005    SANE is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    SANE is distributed in the hope that it will be useful, but WITHOUT
00011    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00012    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
00013    License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with sane; see the file COPYING.  If not, write to the Free
00017    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019    As a special exception, the authors of SANE give permission for
00020    additional uses of the libraries contained in this release of SANE.
00021 
00022    The exception is that, if you link a SANE library with other files
00023    to produce an executable, this does not by itself cause the
00024    resulting executable to be covered by the GNU General Public
00025    License.  Your use of that executable is in no way restricted on
00026    account of linking the SANE library code into it.
00027 
00028    This exception does not, however, invalidate any other reasons why
00029    the executable file might be covered by the GNU General Public
00030    License.
00031 
00032    If you submit changes to SANE to the maintainers to be included in
00033    a subsequent release, you agree by submitting the changes that
00034    those changes may be distributed with this exception intact.
00035 
00036    If you write modifications of your own for SANE, it is your choice
00037    whether to permit this exception to apply to your modifications.
00038    If you do not wish that, delete this exception notice.
00039 
00040    Support routines to translate internal datatypes into a wire-format
00041    (used for RPCs and to save/restore options).  */
00042 
00043 #ifndef sanei_wire_h
00044 #define sanei_wire_h
00045 
00046 #include <sys/types.h>
00047 
00048 #define MAX_MEM (1024 * 1024)
00049 
00050 typedef enum
00051   {
00052     WIRE_ENCODE = 0,
00053     WIRE_DECODE,
00054     WIRE_FREE
00055   }
00056 WireDirection;
00057 
00058 struct Wire;
00059 
00060 typedef void (*WireCodecFunc) (struct Wire *w, void *val_ptr);
00061 typedef ssize_t (*WireReadFunc) (int fd, void * buf, size_t len);
00062 typedef ssize_t (*WireWriteFunc) (int fd, const void * buf, size_t len);
00063 
00064 typedef struct Wire
00065   {
00066     int version;                /* protocol version in use */
00067     WireDirection direction;
00068     int status;
00069     int allocated_memory;
00070     struct
00071       {
00072         WireCodecFunc w_byte;
00073         WireCodecFunc w_char;
00074         WireCodecFunc w_word;
00075         WireCodecFunc w_string;
00076       }
00077     codec;
00078     struct
00079       {
00080         size_t size;
00081         char *curr;
00082         char *start;
00083         char *end;
00084       }
00085     buffer;
00086     struct
00087       {
00088         int fd;
00089         WireReadFunc read;
00090         WireWriteFunc write;
00091       }
00092     io;
00093   }
00094 Wire;
00095 
00096 extern void sanei_w_init (Wire *w, void (*codec_init)(Wire *));
00097 extern void sanei_w_exit (Wire *w);
00098 extern void sanei_w_space (Wire *w, size_t howmuch);
00099 extern void sanei_w_void (Wire *w);
00100 extern void sanei_w_byte (Wire *w, SANE_Byte *v);
00101 extern void sanei_w_char (Wire *w, SANE_Char *v);
00102 extern void sanei_w_word (Wire *w, SANE_Word *v);
00103 extern void sanei_w_bool (Wire *w, SANE_Bool *v);
00104 extern void sanei_w_ptr (Wire *w, void **v, WireCodecFunc w_value,
00105                          size_t value_size);
00106 extern void sanei_w_string (Wire *w, SANE_String *v);
00107 extern void sanei_w_status (Wire *w, SANE_Status *v);
00108 extern void sanei_w_constraint_type (Wire *w, SANE_Constraint_Type *v);
00109 extern void sanei_w_value_type (Wire *w, SANE_Value_Type *v);
00110 extern void sanei_w_unit (Wire *w, SANE_Unit *v);
00111 extern void sanei_w_action (Wire *w, SANE_Action *v);
00112 extern void sanei_w_frame (Wire *w, SANE_Frame *v);
00113 extern void sanei_w_range (Wire *w, SANE_Range *v);
00114 extern void sanei_w_range_ptr (Wire *w, SANE_Range **v);
00115 extern void sanei_w_device (Wire *w, SANE_Device *v);
00116 extern void sanei_w_device_ptr (Wire *w, SANE_Device **v);
00117 extern void sanei_w_option_descriptor (Wire *w, SANE_Option_Descriptor *v);
00118 extern void sanei_w_option_descriptor_ptr (Wire *w,
00119                                            SANE_Option_Descriptor **v);
00120 extern void sanei_w_parameters (Wire *w, SANE_Parameters *v);
00121 
00122 extern void sanei_w_array (Wire *w, SANE_Word *len, void **v,
00123                            WireCodecFunc w_element, size_t element_size);
00124 
00125 extern void sanei_w_set_dir (Wire *w, WireDirection dir);
00126 extern void sanei_w_call (Wire *w, SANE_Word proc_num,
00127                           WireCodecFunc w_arg, void *arg,
00128                           WireCodecFunc w_reply, void *reply);
00129 extern void sanei_w_reply (Wire *w, WireCodecFunc w_reply, void *reply);
00130 extern void sanei_w_free (Wire *w, WireCodecFunc w_reply, void *reply);
00131 
00132 #endif /* sanei_wire_h */

Generated on Sat Jul 26 05:45:27 2008 for SANEI by  doxygen 1.5.1