Re: Porting SANE backends

Svend Daugaard Pedersen (sdp@vip.cybercity.dk)
Mon, 01 Mar 1999 21:14:10 +0100

David Mosberger-Tang wrote:

>>>>>> On Sun, 28 Feb 1999 18:21:32 +0200, Milon Firikis <milonf@ariadne-t.gr>
>said:

> Milon> Note that the objective is to hide all Unix specific
> Milon> functions from the backend much like the sanei_scsi_ routines
> Milon> do for scsi operations.

>You're wrong. Yes, the _API_ must be OS independent but the sample
>implementation that we distribute is developed and intended for
>POSIX-compatible systems. If we can port that source to other
>platforms easily and cleanly, great, but to say that we want to hide
>all UNIX/POSIX specific functions is silly.

>The issue with fork() is that it's hard (inefficient) to implement on
>any system that doesn't have virtual memory. However, threads do not
>necessarily solve the problem either. E.g., on systems supporting
>user-level threads only (e.g., SunOS, HP-UX up to 10.20, etc.), a
>thread may not even help for SANE backends.

>Anyhow, if someone modifies the backends to abstract fork() in an
>elegant way, I'd be happy to merge in such patches. But if it can't
>be done cleanly, you'd be better of creating and maintaining your own
>SANE implementation. It's perfectly OK to have multiple SANE
>implementations as long as they can interoperate.

I think this must be possible. Here is my attempt.

You need four routines:

SANE_Status start_reading(SANE_Handler *h)

If reading from the scanner is to be done by a special process this
routine must set up this process (for instance by calling fork).

Otherwise it should simply return SANE_STATUS_OK.

SANE_Status get_image_data(SANE_Handler *h,SANE_Byte *buf,SANE_Int len)

If a special reader process is up this routine should read the bytes
from the pipe.

Otherwise it should call read_image_data.


SANE_Status stop_reading(SANE_Handler *h)

If a special reader process is up this process has to be killed.

Otherwise return SANE_STATUS_OK.


int reader_process(SANE_Handler *h)

Read bytes from scanner (by calling read_image_data) and write them
to the pipe.

In addition to these four "sanei" routines the following routine must be
supplied by the backend

SANE_Status read_image_data(SANE_Handler *h,SANE_Byte *buf,SANE_Int len)

Svend Daugaard Pedersen

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com