1 /* sane - Scanner Access Now Easy.
2 Copyright (C) 2000-2003 Jochen Eisinger <jochen.eisinger@gmx.net>
3 This file is part of the SANE package.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18 As a special exception, the authors of SANE give permission for
19 additional uses of the libraries contained in this release of SANE.
20
21 The exception is that, if you link a SANE library with other files
22 to produce an executable, this does not by itself cause the
23 resulting executable to be covered by the GNU General Public
24 License. Your use of that executable is in no way restricted on
25 account of linking the SANE library code into it.
26
27 This exception does not, however, invalidate any other reasons why
28 the executable file might be covered by the GNU General Public
29 License.
30
31 If you submit changes to SANE to the maintainers to be included in
32 a subsequent release, you agree by submitting the changes that
33 those changes may be distributed with this exception intact.
34
35 If you write modifications of your own for SANE, it is your choice
36 whether to permit this exception to apply to your modifications.
37 If you do not wish that, delete this exception notice.
38
39 This file implements a SANE backend for Mustek PP flatbed scanners. */
40
41 #include "../include/sane/config.h"
42
43 #if defined(HAVE_STDLIB_H)
44 # include <stdlib.h>
45 #endif
46 #include <ctype.h>
47 #include <stdio.h>
48 #if defined(HAVE_STRING_H)
49 # include <string.h>
50 #elif defined(HAVE_STRINGS_H)
51 # include <strings.h>
52 #endif
53
54 #define DEBUG_DECLARE_ONLY
55
56 #include "mustek_pp.h"
57 #include "mustek_pp_decl.h"
58 #include "../include/sane/sane.h"
59 #include "../include/sane/sanei.h"
60
61 #define MUSTEK_PP_NULL_DRIVER 0
62
63 static SANE_Status
debug_drv_init(SANE_Int options,SANE_String_Const port,SANE_String_Const name,SANE_Attach_Callback attach)64 debug_drv_init(SANE_Int options, SANE_String_Const port,
65 SANE_String_Const name, SANE_Attach_Callback attach)
66 {
67
68 if (options != CAP_NOTHING)
69 return SANE_STATUS_INVAL;
70
71 return attach(port, name, MUSTEK_PP_NULL_DRIVER, 0);
72
73 }
74
75 /*ARGSUSED*/
76 static void
debug_drv_capabilities(SANE_Int info __UNUSED__,SANE_String * model,SANE_String * vendor,SANE_String * type,SANE_Int * maxres,SANE_Int * minres,SANE_Int * maxhsize,SANE_Int * maxvsize,SANE_Int * caps)77 debug_drv_capabilities(SANE_Int info __UNUSED__, SANE_String *model,
78 SANE_String *vendor, SANE_String *type,
79 SANE_Int *maxres, SANE_Int *minres,
80 SANE_Int *maxhsize, SANE_Int *maxvsize,
81 SANE_Int *caps)
82 {
83
84 *model = strdup("debugger");
85 *vendor = strdup("mustek_pp");
86 *type = strdup("software emulated");
87 *maxres = 300;
88 *minres = 50;
89 *maxhsize = 1000;
90 *maxvsize = 3000;
91 *caps = CAP_NOTHING;
92
93 }
94
95 /*ARGSUSED*/
96 static SANE_Status
debug_drv_open(SANE_String port __UNUSED__,SANE_Int caps __UNUSED__,SANE_Int * fd)97 debug_drv_open (SANE_String port __UNUSED__,
98 SANE_Int caps __UNUSED__, SANE_Int *fd)
99 {
100 *fd = 1;
101 return SANE_STATUS_GOOD;
102 }
103
104 static void
debug_drv_setup(SANE_Handle hndl)105 debug_drv_setup (SANE_Handle hndl)
106 {
107
108 Mustek_pp_Handle *dev = hndl;
109
110 dev->lamp_on = 0;
111 dev->priv = NULL;
112 }
113
114 /*ARGSUSED*/
115 static SANE_Status
debug_drv_config(SANE_Handle hndl __UNUSED__,SANE_String_Const optname,SANE_String_Const optval)116 debug_drv_config(SANE_Handle hndl __UNUSED__,
117 SANE_String_Const optname,
118 SANE_String_Const optval)
119 {
120 DBG (3, "debug_drv cfg option: %s=%s\n", optname, optval ? optval : "");
121 return SANE_STATUS_GOOD;
122 }
123
124 /*ARGSUSED*/
125 static void
debug_drv_close(SANE_Handle hndl __UNUSED__)126 debug_drv_close (SANE_Handle hndl __UNUSED__)
127 {
128 }
129
130 /*ARGSUSED*/
131 static SANE_Status
debug_drv_start(SANE_Handle hndl __UNUSED__)132 debug_drv_start (SANE_Handle hndl __UNUSED__)
133 {
134 return SANE_STATUS_GOOD;
135 }
136
137 static void
debug_drv_read(SANE_Handle hndl,SANE_Byte * buffer)138 debug_drv_read (SANE_Handle hndl, SANE_Byte *buffer)
139 {
140
141 Mustek_pp_Handle *dev = hndl;
142
143 memset (buffer, 0, dev->params.bytes_per_line);
144 }
145
146 /*ARGSUSED*/
147 static void
debug_drv_stop(SANE_Handle hndl __UNUSED__)148 debug_drv_stop (SANE_Handle hndl __UNUSED__)
149 {
150
151 }
152