]> pere.pagekite.me Git - homepage.git/blob - linux/sane/19990428-sane-init-return.diff
Switched blog to hungry.com for now. Updated all links.
[homepage.git] / linux / sane / 19990428-sane-init-return.diff
1 diff -ur sane-1.0.1/ChangeLog sane-1.0.1-pere/ChangeLog
2 --- sane-1.0.1/ChangeLog Mon Apr 19 18:21:33 1999
3 +++ sane-1.0.1-pere/ChangeLog Wed Apr 28 00:43:22 1999
4 @@ -1,3 +1,10 @@
5 +1999-04-28 Petter Reinholdtsen <pere@td.org.uit.no>
6 +
7 + * doc/sane.tex frontend/scanimage.c frontend/xcam.c
8 + frontend/xscanimage.c: Specified valid return values for
9 + sane_init(), and made sure all our frontends checks for the
10 + correct return value before using other methods in the backend.
11 +
12 1999-04-19 David Mosberger-Tang <David.Mosberger@acm.org>
13
14 * Version 1.0.1 released.
15 diff -ur sane-1.0.1/doc/sane.tex sane-1.0.1-pere/doc/sane.tex
16 --- sane-1.0.1/doc/sane.tex Sat Apr 3 23:16:07 1999
17 +++ sane-1.0.1-pere/doc/sane.tex Wed Apr 28 00:17:31 1999
18 @@ -1052,9 +1052,11 @@
19
20 This function must be called before any other SANE function can be
21 called. The behavior of a SANE backend is undefined if this function
22 -is not called first. The version code of the backend is returned in
23 -the value pointed to by \code{version\_code}. If that pointer is
24 -\code{NULL}, no version code is returned.
25 +is not called first. The behavior of a backend is also undefined if
26 +this function returns anything other then \code{SANE\_STATUS\_GOOD}.
27 +The version code of the backend is returned in the value pointed to by
28 +\code{version\_code}. If that pointer is \code{NULL}, no version code
29 +is returned.
30 Argument \code{authorize} is either a pointer to a function that is
31 invoked when the backend requires authentication for a specific
32 resource or \code{NULL} if the frontend does not support
33 @@ -1064,6 +1066,16 @@
34 SANE_Status sane_init (SANE_Int * version_code,
35 SANE_Authorization_Callback authorize);
36 \end{verbatim}
37 +\end{quote}
38 +
39 +This function may fail with one of the following status codes.
40 +\begin{quote}
41 +\begin{description}
42 +\item[\code{SANE\_STATUS\_UNSUPPORTED}:] The backend is not supported on
43 + this machines current configuration.
44 +\item[\code{SANE\_STATUS\_NO\_MEM}:] An insufficent amount of memory
45 + is available to complete. Try later when more memory is available.
46 +\end{description}
47 \end{quote}
48
49 The authorization function may be called by a backend in response to
50 diff -ur sane-1.0.1/frontend/scanimage.c sane-1.0.1-pere/frontend/scanimage.c
51 --- sane-1.0.1/frontend/scanimage.c Fri Mar 5 07:13:49 1999
52 +++ sane-1.0.1-pere/frontend/scanimage.c Wed Apr 28 00:28:44 1999
53 @@ -73,6 +73,7 @@
54 static SANE_Handle device;
55 static int verbose;
56 static int test;
57 +static int list;
58 static int help;
59 static const char * prog_name;
60 static SANE_Option_Descriptor window_option[2];
61 @@ -1041,6 +1042,29 @@
62 free (image.data);
63 }
64
65 +void
66 +list_devices(void)
67 +{
68 + const SANE_Device ** device_list;
69 + SANE_Status status;
70 + int i;
71 +
72 + status = sane_get_devices (&device_list, SANE_FALSE);
73 + if (status != SANE_STATUS_GOOD)
74 + {
75 + fprintf (stderr, "%s: sane_get_devices() failed: %s\n",
76 + prog_name, sane_strstatus (status));
77 + return;
78 + }
79 +
80 + for (i = 0; device_list[i]; ++i)
81 + {
82 + printf ("device `%s' is a %s %s %s\n",
83 + device_list[i]->name, device_list[i]->vendor,
84 + device_list[i]->model, device_list[i]->type);
85 + }
86 +}
87 +
88 int
89 main (int argc, char **argv)
90 {
91 @@ -1060,8 +1084,6 @@
92 else
93 prog_name = argv[0];
94
95 - sane_init (0, 0);
96 -
97 /* make a first pass through the options with error printing and argument
98 permutation disabled: */
99 opterr = 0;
100 @@ -1079,27 +1101,7 @@
101 case 'h': help = 1; break;
102 case 'v': ++verbose; break;
103 case 'T': test= 1; break;
104 - case 'L':
105 - {
106 - int i;
107 -
108 - status = sane_get_devices (&device_list, SANE_FALSE);
109 - if (status != SANE_STATUS_GOOD)
110 - {
111 - fprintf (stderr, "%s: sane_get_devices() failed: %s\n",
112 - prog_name, sane_strstatus (status));
113 - exit (1);
114 - }
115 -
116 - for (i = 0; device_list[i]; ++i)
117 - {
118 - printf ("device `%s' is a %s %s %s\n",
119 - device_list[i]->name, device_list[i]->vendor,
120 - device_list[i]->model, device_list[i]->type);
121 - }
122 - exit (0);
123 - }
124 -
125 + case 'L': list = 1; break;
126 case 'V':
127 printf ("scanimage (%s) %s\n", PACKAGE, VERSION);
128 exit (0);
129 @@ -1122,6 +1124,18 @@
130 -v, --verbose give even more status messages\n\
131 -V, --version print version information\n",
132 prog_name);
133 +
134 + if (SANE_STATUS_GOOD != sane_init (NULL, NULL))
135 + {
136 + fprintf(stderr,"sane_init() failed. Unable to do anything. Exiting\n");
137 + return(1);
138 + }
139 +
140 + if (list)
141 + {
142 + list_devices();
143 + return(0);
144 + }
145
146 if (!devname)
147 {
148 diff -ur sane-1.0.1/frontend/xcam.c sane-1.0.1-pere/frontend/xcam.c
149 --- sane-1.0.1/frontend/xcam.c Sat Apr 4 06:39:20 1998
150 +++ sane-1.0.1-pere/frontend/xcam.c Tue Apr 27 23:54:56 1999
151 @@ -894,7 +894,11 @@
152 /* turn on by default as we don't support graphical geometry selection */
153 preferences.advanced = 1;
154
155 - sane_init (NULL, 0);
156 + if (SANE_STATUS_GOOD != sane_init (NULL, NULL))
157 + {
158 + fprintf(stderr,"sane_init() failed. Unable to do anything. Exiting\n");
159 + return(1);
160 + }
161
162 gdk_set_show_events (0);
163 gtk_init (&argc, &argv);
164 diff -ur sane-1.0.1/frontend/xscanimage.c sane-1.0.1-pere/frontend/xscanimage.c
165 --- sane-1.0.1/frontend/xscanimage.c Sat Apr 3 06:07:57 1999
166 +++ sane-1.0.1-pere/frontend/xscanimage.c Tue Apr 27 23:56:42 1999
167 @@ -257,7 +257,12 @@
168 nargs, nreturn_vals,
169 args, return_vals);
170
171 - sane_init (0, 0);
172 + if (SANE_STATUS_GOOD != sane_init (NULL, NULL))
173 + {
174 + fprintf(stderr,"sane_init() failed. Unable to do anything. Exiting\n");
175 + return(1);
176 + }
177 +
178 sane_get_devices (&devlist, SANE_FALSE);
179
180 for (i = 0; devlist[i]; ++i)