• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SANE - Scanner Access Now Easy.
2 
3    Copyright (C) 2008 by Louis Lagendijk
4    based on sane_usb.h:
5    Copyright (C) 2003, 2005 Rene Rebe (sanei_read_int,sanei_set_timeout)
6    Copyright (C) 2001, 2002 Henning Meier-Geinitz
7 
8    This file is part of the SANE package.
9 
10    SANE is free software; you can redistribute it and/or modify it
11    under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14 
15    SANE is distributed in the hope that it will be useful, but WITHOUT
16    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
18    License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with sane; see the file COPYING.
22    If not, see <https://www.gnu.org/licenses/>.
23 
24    As a special exception, the authors of SANE give permission for
25    additional uses of the libraries contained in this release of SANE.
26 
27    The exception is that, if you link a SANE library with other files
28    to produce an executable, this does not by itself cause the
29    resulting executable to be covered by the GNU General Public
30    License.  Your use of that executable is in no way restricted on
31    account of linking the SANE library code into it.
32 
33    This exception does not, however, invalidate any other reasons why
34    the executable file might be covered by the GNU General Public
35    License.
36 
37    If you submit changes to SANE to the maintainers to be included in
38    a subsequent release, you agree by submitting the changes that
39    those changes may be distributed with this exception intact.
40 
41    If you write modifications of your own for SANE, it is your choice
42    whether to permit this exception to apply to your modifications.
43    If you do not wish that, delete this exception notice.
44 */
45 /** @file sanei_bjnp.h
46  * This file provides a generic BJNP interface.
47  */
48 
49 #ifndef sanei_bjnp_h
50 #define sanei_bjnp_h
51 
52 #include "../include/sane/config.h"
53 #include "../include/sane/sane.h"
54 #include "pixma.h"
55 
56 #ifdef HAVE_STDLIB_H
57 #include <stdlib.h>		/* for size_t */
58 #endif
59 
60 /** Initialize sanei_bjnp.
61  *
62  * Call this before any other sanei_bjnp function.
63  */
64 extern void sanei_bjnp_init (void);
65 
66 /** Find scanners responding to a BJNP broadcast.
67  *
68  * The function sanei_bjnp_attach is called for every device which has
69  * been found.
70  * Serial is the address of the scanner in human readable form of max
71  * SERIAL_MAX characters
72  * @param conf_devices list of pre-configures device URI's to attach
73  * @param attach attach function
74  * @param pixma_devices device informatio needed by attach function
75  *
76  * @return SANE_STATUS_GOOD - on success (even if no scanner was found)
77  */
78 
79 #define SERIAL_MAX 16
80 
81 extern SANE_Status
82 sanei_bjnp_find_devices (const char **conf_devices,
83                          SANE_Status (*attach_bjnp)
84 			     (SANE_String_Const devname,
85                                SANE_String_Const serial,
86 			       const struct pixma_config_t *cfg),
87                          const struct pixma_config_t *const pixma_devices[]);
88 
89 /** Open a BJNP device.
90  *
91  * The device is opened by its name devname and the device number is
92  * returned in dn on success.
93  *
94  * Device names consist of an URI
95  * Where:
96  * method = bjnp
97  * hostname = resolvable name or IP-address
98  * port = 8612 for a bjnp scanner, 8610 for a mfnp device
99  * An example could look like this: bjnp://host.domain:8612
100  *
101  * @param devname name of the device to open
102  * @param dn device number
103  *
104  * @return
105  * - SANE_STATUS_GOOD - on success
106  * - SANE_STATUS_ACCESS_DENIED - if the file couldn't be accessed due to
107  *   permissions
108  * - SANE_STATUS_INVAL - on every other error
109  */
110 extern SANE_Status sanei_bjnp_open (SANE_String_Const devname, SANE_Int * dn);
111 
112 /** Close a BJNP device.
113  *
114  * @param dn device number
115  */
116 
117 extern void sanei_bjnp_close (SANE_Int dn);
118 
119 /** Activate a BJNP device connection
120  *
121  *  @param dn device number
122  */
123 
124 extern SANE_Status sanei_bjnp_activate (SANE_Int dn);
125 
126 /** De-activate a BJNP device connection
127  *
128  * @param dn device number
129  */
130 
131 extern SANE_Status sanei_bjnp_deactivate (SANE_Int dn);
132 
133 /** Set the libbjnp timeout for bulk and interrupt reads.
134  *
135  * @param devno device number
136  * @param timeout the new timeout in ms
137  */
138 extern void sanei_bjnp_set_timeout (SANE_Int devno, SANE_Int timeout);
139 
140 /** Check if sanei_bjnp_set_timeout() is available.
141  */
142 #define HAVE_SANEI_BJNP_SET_TIMEOUT
143 
144 /** Initiate a bulk transfer read.
145  *
146  * Read up to size bytes from the device to buffer. After the read, size
147  * contains the number of bytes actually read.
148  *
149  * @param dn device number
150  * @param buffer buffer to store read data in
151  * @param size size of the data
152  *
153  * @return
154  * - SANE_STATUS_GOOD - on success
155  * - SANE_STATUS_EOF - if zero bytes have been read
156  * - SANE_STATUS_IO_ERROR - if an error occurred during the read
157  * - SANE_STATUS_INVAL - on every other error
158  *
159  */
160 extern SANE_Status
161 sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size);
162 
163 /** Initiate a bulk transfer write.
164  *
165  * Write up to size bytes from buffer to the device. After the write size
166  * contains the number of bytes actually written.
167  *
168  * @param dn device number
169  * @param buffer buffer to write to device
170  * @param size size of the data
171  *
172  * @return
173  * - SANE_STATUS_GOOD - on success
174  * - SANE_STATUS_IO_ERROR - if an error occurred during the write
175  * - SANE_STATUS_INVAL - on every other error
176  */
177 extern SANE_Status
178 sanei_bjnp_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size);
179 
180 /** Initiate a interrupt transfer read.
181  *
182  * Read up to size bytes from the interrupt endpoint from the device to
183  * buffer. After the read, size contains the number of bytes actually read.
184  *
185  * @param dn device number
186  * @param buffer buffer to store read data in
187  * @param size size of the data
188  *
189  * @return
190  * - SANE_STATUS_GOOD - on success
191  * - SANE_STATUS_EOF - if zero bytes have been read
192  * - SANE_STATUS_IO_ERROR - if an error occurred during the read
193  * - SANE_STATUS_INVAL - on every other error
194  *
195  */
196 
197 extern SANE_Status
198 sanei_bjnp_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size);
199 
200 /*------------------------------------------------------*/
201 #endif /* sanei_bjnp_h */
202