SANEI 1.3.1.72-4c77c
sanei_wire.h
1/* sane - Scanner Access Now Easy.
2 Copyright (C) 1997 David Mosberger-Tang
3 This file is part of the SANE package.
4
5 SANE is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 SANE is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
13 License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with sane; see the file COPYING.
17 If not, see <https://www.gnu.org/licenses/>.
18
19 As a special exception, the authors of SANE give permission for
20 additional uses of the libraries contained in this release of SANE.
21
22 The exception is that, if you link a SANE library with other files
23 to produce an executable, this does not by itself cause the
24 resulting executable to be covered by the GNU General Public
25 License. Your use of that executable is in no way restricted on
26 account of linking the SANE library code into it.
27
28 This exception does not, however, invalidate any other reasons why
29 the executable file might be covered by the GNU General Public
30 License.
31
32 If you submit changes to SANE to the maintainers to be included in
33 a subsequent release, you agree by submitting the changes that
34 those changes may be distributed with this exception intact.
35
36 If you write modifications of your own for SANE, it is your choice
37 whether to permit this exception to apply to your modifications.
38 If you do not wish that, delete this exception notice.
39
40 Support routines to translate internal datatypes into a wire-format
41 (used for RPCs and to save/restore options). */
42
43#ifndef sanei_wire_h
44#define sanei_wire_h
45
46#include <sys/types.h>
47
48#define MAX_MEM (1024 * 1024)
49
50typedef enum
51 {
52 WIRE_ENCODE = 0,
53 WIRE_DECODE,
54 WIRE_FREE
55 }
56WireDirection;
57
58struct Wire;
59
60typedef void (*WireCodecFunc) (struct Wire *w, void *val_ptr);
61typedef ssize_t (*WireReadFunc) (int fd, void * buf, size_t len);
62typedef ssize_t (*WireWriteFunc) (int fd, const void * buf, size_t len);
63
64typedef struct Wire
65 {
66 int version; /* protocol version in use */
67 WireDirection direction;
68 int status;
69 int allocated_memory;
70 struct
71 {
72 WireCodecFunc w_byte;
73 WireCodecFunc w_char;
74 WireCodecFunc w_word;
75 WireCodecFunc w_string;
76 }
77 codec;
78 struct
79 {
80 size_t size;
81 char *curr;
82 char *start;
83 char *end;
84 }
85 buffer;
86 struct
87 {
88 int fd;
89 WireReadFunc read;
90 WireWriteFunc write;
91 }
92 io;
93 }
94Wire;
95
96extern void sanei_w_init (Wire *w, void (*codec_init)(Wire *));
97extern void sanei_w_exit (Wire *w);
98extern void sanei_w_space (Wire *w, size_t howmuch);
99extern void sanei_w_void (Wire *w, void *);
100extern void sanei_w_byte (Wire *w, SANE_Byte *v);
101extern void sanei_w_char (Wire *w, SANE_Char *v);
102extern void sanei_w_word (Wire *w, SANE_Word *v);
103extern void sanei_w_bool (Wire *w, SANE_Bool *v);
104extern void sanei_w_ptr (Wire *w, void **v, WireCodecFunc w_value,
105 size_t value_size);
106extern void sanei_w_string (Wire *w, SANE_String *v);
107extern void sanei_w_status (Wire *w, SANE_Status *v);
108extern void sanei_w_constraint_type (Wire *w, SANE_Constraint_Type *v);
109extern void sanei_w_value_type (Wire *w, SANE_Value_Type *v);
110extern void sanei_w_unit (Wire *w, SANE_Unit *v);
111extern void sanei_w_action (Wire *w, SANE_Action *v);
112extern void sanei_w_frame (Wire *w, SANE_Frame *v);
113extern void sanei_w_range (Wire *w, SANE_Range *v);
114extern void sanei_w_range_ptr (Wire *w, SANE_Range **v);
115extern void sanei_w_device (Wire *w, SANE_Device *v);
116extern void sanei_w_device_ptr (Wire *w, SANE_Device **v);
117extern void sanei_w_option_descriptor (Wire *w, SANE_Option_Descriptor *v);
118extern void sanei_w_option_descriptor_ptr (Wire *w,
119 SANE_Option_Descriptor **v);
120extern void sanei_w_parameters (Wire *w, SANE_Parameters *v);
121
122extern void sanei_w_array (Wire *w, SANE_Word *len, void **v,
123 WireCodecFunc w_element, size_t element_size);
124
125extern void sanei_w_set_dir (Wire *w, WireDirection dir);
126extern void sanei_w_call (Wire *w, SANE_Word proc_num,
127 WireCodecFunc w_arg, void *arg,
128 WireCodecFunc w_reply, void *reply);
129extern void sanei_w_reply (Wire *w, WireCodecFunc w_reply, void *reply);
130extern void sanei_w_free (Wire *w, WireCodecFunc w_reply, void *reply);
131
132#endif /* sanei_wire_h */
SANE_Status ENTRY() read(SANE_Handle, SANE_Byte *, SANE_Int, SANE_Int *)
Internationalization for SANE backends.
SANE_Status ENTRY() start(SANE_Handle)
Internationalization for SANE backends.