[sane-devel] [RFC][PATCH] sanei configuration framework extension

stef stef.dev at free.fr
Mon Jun 23 19:36:45 UTC 2008


Le Thursday 19 June 2008 15:36:59 m. allan noah, vous avez écrit :
> pretty good, but i have two comments:
>
> 1. i think calling the struct SANE_Config instead of something with
> sanei in it, makes it look too much like something that should be in
> the SANE standard, instead of the internal-use function that it is.
>
> 2. some backends seem to have dozens of options, that struct is going
> to become quite large if it is extending to hold everything. does it
> instead make more sense for the callback to be run for each line
> extracted from the file, with a flag indicating that it was an option
> instead of an attach line?
>
> allan
>

	Hello,

	here's a new take at config option parsing. The struct is now called 
SANEI_Config, and holds an array of SANE_Option_Descriptor and an array of 
placeholder for the values of the options. To parse options, a backend first 
creates a list of the options it wants using SANE_Option_Descriptor. Then
it calls sanei_configure_initialize() which creates the placeholders.
	When the SANEI_Config is ready, the backend calls sanei_configure_attach() 
which opens the configuration, parse it according to the given descriptors. 
Whenever a line no recognized as an option is met, the 
sanei_configure_attach() calls the backend provided (*attach)(SANEI_Config *, 
char *devname) attach function. This backend specific function calls the 
usb/scsi/parport attach functions allready provided by sanei library. As a 
parameter it has the currently parsed options in the config struct and so may 
use them during the attach. A sanei_configure_get_value() helper is given to 
access the values of the options.
	Once parsing is done, there is a sanei_configure_dispose() function to 
release allocated ressources.
	
	By doing this way, configuration is parsed only with the options the backend 
needs. The existing sanei_check_value() may be reused to check if constraints 
are respected.  Only a couple options that need a complex syntax couldn't be 
handled right now (such as 'calibrate /path/name port' from canon_pp) but 
could be handled by a SANE_TYPE_STRING_LIST to be created.

	The appended patch currently only manage SANE_TYPE_STRING options and as been 
tested with a modified rts8891 backend. 

Regards,
	Stef


-------------- next part --------------
A non-text attachment was scrubbed...
Name: proposal.patch.gz
Type: application/x-gzip
Size: 4841 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/sane-devel/attachments/20080623/81b6169c/attachment.bin 


More information about the sane-devel mailing list