[sane-devel] [RFC] sanei configuration framework improvement

m. allan noah kitno455 at gmail.com
Thu Jul 24 14:42:07 UTC 2008


you will have to do the same for scsi, so this seems like a fair bit
of code duplication.

how about hiding the existing sanei_* functions, and calling them from
wrappers? something like:

/*PRIVATE*/
_sanei_usb_attach_matching_devices (
  const char *name,
  SANE_Status (*attach) (const char *dev)
  SANE_Status (*attach2) (const char *dev, SANEI_Config * config)
){

  do_stuff...

  if(attach){
    attach()
  }
  else if(attach2){
    attach2()
  }
  else{
    DBG()
  }
}

/*PUBLIC*/
sanei_usb_attach_matching_devices (
  const char *name,
  SANE_Status (*attach) (const char *dev)
){
  _sanei_usb_attach_matching_devices(dev,attach,NULL)
}

sanei_usb_attach_matching_devices2 (
  const char *name,
  SANE_Status (*attach) (const char *dev, SANEI_Config * config)
){
  _sanei_usb_attach_matching_devices(dev,NULL,attach2)
}

allan

On Tue, Jul 15, 2008 at 1:58 AM, stef <stef.dev at free.fr> wrote:
>        Hello,
>
>        currently, the sanei_usb_find_devices() and
> sanei_usb_attach_matching_devices() functions use an attach callback which
> has only a 'name' parameter. So when parsing configuration options quite a
> few backends store options in global vars to use them at attach time. Now we
> have a SANEI_Config structure, I'd like to add it to the parameters so that
> we can pass it to attach function and avoid the use of global vars.
>        This would made the use of sanei_configure_attach() even simpler, since a
> backend would only need this attach with config struct callback to work. USB
> backends with no options would even only need to  add this parameter (leaving
> it unused) to their current attach function and call
> sanei_configure_attach().
>        Since I suppose backend maintainers would rather avoid their backend modified
> to add an unused parameter. I'm thinking about duplicating these two
> sanei_usb functions.
>        Would it be OK that way ?
>
> Regards,
>        Stef
>
> --
> sane-devel mailing list: sane-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>             to sane-devel-request at lists.alioth.debian.org
>



-- 
"The truth is an offense, but not a sin"



More information about the sane-devel mailing list