kopia lustrzana https://gitlab.com/sane-project/website
716 wiersze
15 KiB
HTML
716 wiersze
15 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
|
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>sane-devel: Re: dll backend: aliased & hidden device names</TITLE>
|
|
<META NAME="Author" CONTENT="Ingo Wilken (Ingo.Wilken@Informatik.Uni-Oldenburg.DE)">
|
|
<META NAME="Subject" CONTENT="Re: dll backend: aliased & hidden device names">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
|
|
<H1>Re: dll backend: aliased & hidden device names</H1>
|
|
<!-- received="Wed Jan 26 14:37:50 2000" -->
|
|
<!-- isoreceived="20000126223750" -->
|
|
<!-- sent="Wed, 26 Jan 2000 23:40:31 +0100 (MET)" -->
|
|
<!-- isosent="20000126224031" -->
|
|
<!-- name="Ingo Wilken" -->
|
|
<!-- email="Ingo.Wilken@Informatik.Uni-Oldenburg.DE" -->
|
|
<!-- subject="Re: dll backend: aliased & hidden device names" -->
|
|
<!-- id="m12Db71-000ILSC@petersfehn.Informatik.Uni-Oldenburg.DE" -->
|
|
<!-- inreplyto="200001260400.MAA14244@minerva.ee.uwa.edu.au" -->
|
|
<STRONG>From:</STRONG> Ingo Wilken (<A HREF="mailto:Ingo.Wilken@Informatik.Uni-Oldenburg.DE?Subject=Re:%20dll%20backend:%20aliased%20&%20hidden%20device%20names&In-Reply-To=<m12Db71-000ILSC@petersfehn.Informatik.Uni-Oldenburg.DE>"><EM>Ingo.Wilken@Informatik.Uni-Oldenburg.DE</EM></A>)<BR>
|
|
<STRONG>Date:</STRONG> Wed Jan 26 2000 - 14:40:31 PST
|
|
<P>
|
|
<!-- next="start" -->
|
|
<LI><STRONG>Next message:</STRONG> <A HREF="0252.html">jes@presto.med.upenn.edu: "Re: Semi OT: SCSI termination question"</A>
|
|
<UL>
|
|
<LI><STRONG>Previous message:</STRONG> <A HREF="0250.html">Jonathan Buzzard: "Re: Update: Linux USB and Scanners"</A>
|
|
<!-- nextthread="start" -->
|
|
<!-- reply="end" -->
|
|
<LI><STRONG>Messages sorted by:</STRONG>
|
|
<A HREF="date.html#251">[ date ]</A>
|
|
<A HREF="index.html#251">[ thread ]</A>
|
|
<A HREF="subject.html#251">[ subject ]</A>
|
|
<A HREF="author.html#251">[ author ]</A>
|
|
</UL>
|
|
<HR NOSHADE><P>
|
|
<!-- body="start" -->
|
|
<P>
|
|
Hi
|
|
<BR>
|
|
<P><EM>> I'm currently collecting SANE patches, and was planning to test your
|
|
</EM><BR>
|
|
<EM>> dll alias patch. Unfortunately, the only version I have available is
|
|
</EM><BR>
|
|
<EM>> <URL:<A HREF="http://www.mostang.com/mail-archive/sane-devel/1999-07/0007.html">http://www.mostang.com/mail-archive/sane-devel/1999-07/0007.html</A>>,
|
|
</EM><BR>
|
|
<EM>> which is filled with HTML tags. :-(
|
|
</EM><BR>
|
|
<EM>> Could you send me the latest version of you patch, possibly relative
|
|
</EM><BR>
|
|
<EM>> to the latest SANE CVS snapshot,
|
|
</EM><BR>
|
|
<EM>> <URL:<A HREF="http://www.student.uit.no/~pere/linux/sane/sane-devel-20000123.tar.gz">http://www.student.uit.no/~pere/linux/sane/sane-devel-20000123.tar.gz</A>>?
|
|
</EM><BR>
|
|
<P>I did no further work on the aliases/hidden stuff. The old patch is
|
|
<BR>
|
|
appended below. I'll create a new patch relative to the CVS snapshot
|
|
<BR>
|
|
when I get it to my home machine (possibly next week - I'm currently only
|
|
<BR>
|
|
reading mail via a dead slow modem link and long distance call, so I'm not
|
|
<BR>
|
|
going to download anything larger than a few KB).
|
|
<BR>
|
|
<P>For best results, there should be a modification to the SANE API so programs
|
|
<BR>
|
|
(and special backends like the net backend) can request unaliased device
|
|
<BR>
|
|
names in sane_get_devices(). It's a minor modification:
|
|
<BR>
|
|
SANE_Status sane_get_devices(const SANE_Device ***dev, SANE_Bool local_only)
|
|
<BR>
|
|
would become something like
|
|
<BR>
|
|
SANE_Status sane_get_devices(const SANE_Device ***dev, SANE_Flags flags)
|
|
<BR>
|
|
with two possible flags:
|
|
<BR>
|
|
#define SANEF_LOCAL_ONLY 0x01
|
|
<BR>
|
|
#define SANEF_UNALIASED 0x02
|
|
<BR>
|
|
<P>Regards,
|
|
<BR>
|
|
Ingo
|
|
<BR>
|
|
<P>--- my old mail with the patch: ---
|
|
<BR>
|
|
This is a first attempt to add device names aliases and hidden
|
|
<BR>
|
|
devices to the dll backend. It works ok here, so I'm releasing
|
|
<BR>
|
|
the patches and ask for your comments.
|
|
<BR>
|
|
<P>Aliases are defined in the new config file "dll.aliases".
|
|
<BR>
|
|
This can contain entries of the form
|
|
<BR>
|
|
<P> alias SomeName SaneDeviceName
|
|
<BR>
|
|
alias "Some Name" SaneDeviceName
|
|
<BR>
|
|
hide SaneDeviceName
|
|
<BR>
|
|
<P>For example:
|
|
<BR>
|
|
<P> alias Epson net:somehost:epson:/dev/sgX
|
|
<BR>
|
|
alias "Siemens ST400" st400:/dev/sgY
|
|
<BR>
|
|
hide net:somehost:pnm:0
|
|
<BR>
|
|
hide net:somehost:pnm:1
|
|
<BR>
|
|
alias "Read from file" pnm:0
|
|
<BR>
|
|
hide pnm:1
|
|
<BR>
|
|
<P>Aliased device names are automatically hidden.
|
|
<BR>
|
|
<P>The idea is that users don't have to deal with complicated device
|
|
<BR>
|
|
names (especially for networked devices), and to hide other exported
|
|
<BR>
|
|
devices which might confuse them. Note that a hidden device can still
|
|
<BR>
|
|
be accessed if the device name is known, it just doesn't appear on
|
|
<BR>
|
|
the list.
|
|
<BR>
|
|
<P>Regards,
|
|
<BR>
|
|
Ingo
|
|
<BR>
|
|
<P><P>*** dll.c.orig Tue Apr 27 06:35:12 1999
|
|
<BR>
|
|
--- dll.c Fri Jul 2 19:24:42 1999
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 91,96 ****
|
|
<BR>
|
|
--- 91,97 ----
|
|
<BR>
|
|
|
|
<BR>
|
|
#include <sane/sanei_config.h>
|
|
<BR>
|
|
#define DLL_CONFIG_FILE "dll.conf"
|
|
<BR>
|
|
+ #define DLL_ALIASES_FILE "dll.aliases"
|
|
<BR>
|
|
|
|
<BR>
|
|
enum SANE_Ops
|
|
<BR>
|
|
{
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 170,175 ****
|
|
<BR>
|
|
--- 171,184 ----
|
|
<BR>
|
|
SANE_Handle handle;
|
|
<BR>
|
|
};
|
|
<BR>
|
|
|
|
<BR>
|
|
+ struct alias
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ struct alias *next;
|
|
<BR>
|
|
+ char *oldname;
|
|
<BR>
|
|
+ char *newname;
|
|
<BR>
|
|
+ };
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ static struct alias *first_alias;
|
|
<BR>
|
|
static SANE_Auth_Callback auth_callback;
|
|
<BR>
|
|
static struct backend *first_backend;
|
|
<BR>
|
|
static const char *op_name[] =
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 302,308 ****
|
|
<BR>
|
|
--- 311,321 ----
|
|
<BR>
|
|
#endif /* HAVE_DLOPEN */
|
|
<BR>
|
|
if (!be->handle)
|
|
<BR>
|
|
{
|
|
<BR>
|
|
+ #ifdef HAVE_DLOPEN
|
|
<BR>
|
|
+ DBG(2, "dlopen() failed (%s)\n", dlerror ());
|
|
<BR>
|
|
+ #else
|
|
<BR>
|
|
DBG(2, "dlopen() failed (%s)\n", strerror (errno));
|
|
<BR>
|
|
+ #endif /* HAVE_DLOPEN */
|
|
<BR>
|
|
return SANE_STATUS_INVAL;
|
|
<BR>
|
|
}
|
|
<BR>
|
|
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 379,384 ****
|
|
<BR>
|
|
--- 392,478 ----
|
|
<BR>
|
|
return SANE_STATUS_GOOD;
|
|
<BR>
|
|
}
|
|
<BR>
|
|
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ static void
|
|
<BR>
|
|
+ add_alias (char *line)
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ const char *command;
|
|
<BR>
|
|
+ enum { CMD_ALIAS, CMD_HIDE } cmd;
|
|
<BR>
|
|
+ const char *oldname, *oldend, *newname, *newend;
|
|
<BR>
|
|
+ size_t oldlen, newlen;
|
|
<BR>
|
|
+ struct alias *alias;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ command = sanei_config_skip_whitespace(line);
|
|
<BR>
|
|
+ if( !*command )
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+ line = strpbrk(command, " \t");
|
|
<BR>
|
|
+ if( !line )
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+ *line++ = '\0';
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ if( strcmp(command, "alias") == 0 )
|
|
<BR>
|
|
+ cmd = CMD_ALIAS;
|
|
<BR>
|
|
+ else
|
|
<BR>
|
|
+ if( strcmp(command, "hide") == 0 )
|
|
<BR>
|
|
+ cmd = CMD_HIDE;
|
|
<BR>
|
|
+ else
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ newlen = 0;
|
|
<BR>
|
|
+ newname = NULL;
|
|
<BR>
|
|
+ if( cmd == CMD_ALIAS )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ newname = sanei_config_skip_whitespace(line);
|
|
<BR>
|
|
+ if( !*newname )
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+ if( *newname == '\"' )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ ++newname;
|
|
<BR>
|
|
+ newend = strchr(newname, '\"');
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+ else
|
|
<BR>
|
|
+ newend = strpbrk(newname, " \t");
|
|
<BR>
|
|
+ if( !newend )
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ newlen = newend - newname;
|
|
<BR>
|
|
+ line = (char*)(newend+1);
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ oldname = sanei_config_skip_whitespace(line);
|
|
<BR>
|
|
+ if( !*oldname )
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+ oldend = oldname + strcspn(oldname, " \t");
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ oldlen = oldend - oldname;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ alias = malloc(sizeof(struct alias));
|
|
<BR>
|
|
+ if( alias )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ alias->oldname = malloc(oldlen + newlen + 2);
|
|
<BR>
|
|
+ if( alias->oldname )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ strncpy(alias->oldname, oldname, oldlen);
|
|
<BR>
|
|
+ alias->oldname[oldlen] = '\0';
|
|
<BR>
|
|
+ if( cmd == CMD_ALIAS )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ alias->newname = alias->oldname + oldlen + 1;
|
|
<BR>
|
|
+ strncpy(alias->newname, newname, newlen);
|
|
<BR>
|
|
+ alias->newname[newlen] = '\0';
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+ else
|
|
<BR>
|
|
+ alias->newname = NULL;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ alias->next = first_alias;
|
|
<BR>
|
|
+ first_alias = alias;
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+ free(alias);
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+ return;
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+
|
|
<BR>
|
|
SANE_Status
|
|
<BR>
|
|
sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
|
|
<BR>
|
|
{
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 422,427 ****
|
|
<BR>
|
|
--- 516,539 ----
|
|
<BR>
|
|
}
|
|
<BR>
|
|
fclose (fp);
|
|
<BR>
|
|
|
|
<BR>
|
|
+ fp = sanei_config_open (DLL_ALIASES_FILE);
|
|
<BR>
|
|
+ if (!fp)
|
|
<BR>
|
|
+ return SANE_STATUS_GOOD; /* don't insist on aliases file */
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ while (fgets (backend_name, sizeof (backend_name), fp))
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ if (backend_name[0] == '#') /* ignore line comments */
|
|
<BR>
|
|
+ continue;
|
|
<BR>
|
|
+ len = strlen (backend_name);
|
|
<BR>
|
|
+ if (backend_name[len - 1] == '\n')
|
|
<BR>
|
|
+ backend_name[--len] = '\0';
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ if (!len)
|
|
<BR>
|
|
+ continue; /* ignore empty lines */
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ add_alias (backend_name);
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+ fclose (fp);
|
|
<BR>
|
|
return SANE_STATUS_GOOD;
|
|
<BR>
|
|
}
|
|
<BR>
|
|
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 429,434 ****
|
|
<BR>
|
|
--- 541,547 ----
|
|
<BR>
|
|
sane_exit (void)
|
|
<BR>
|
|
{
|
|
<BR>
|
|
struct backend *be, *next;
|
|
<BR>
|
|
+ struct alias *alias;
|
|
<BR>
|
|
|
|
<BR>
|
|
DBG(1, "exiting\n");
|
|
<BR>
|
|
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 461,466 ****
|
|
<BR>
|
|
--- 574,586 ----
|
|
<BR>
|
|
}
|
|
<BR>
|
|
}
|
|
<BR>
|
|
first_backend = 0;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ while( (alias = first_alias) != NULL )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ first_alias = first_alias->next;
|
|
<BR>
|
|
+ free(alias->oldname);
|
|
<BR>
|
|
+ free(alias);
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
}
|
|
<BR>
|
|
|
|
<BR>
|
|
/* Note that a call to get_devices() implies that we'll have to load
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 517,535 ****
|
|
<BR>
|
|
{
|
|
<BR>
|
|
SANE_Device *dev;
|
|
<BR>
|
|
char *mem;
|
|
<BR>
|
|
|
|
<BR>
|
|
! /* create a new device entry with a device name that is the
|
|
<BR>
|
|
! sum of the backend name a colon and the backend's device
|
|
<BR>
|
|
! name: */
|
|
<BR>
|
|
! len = strlen (be->name) + 1 + strlen (be_list[i]->name);
|
|
<BR>
|
|
! mem = malloc (sizeof (*dev) + len + 1);
|
|
<BR>
|
|
! if (!mem)
|
|
<BR>
|
|
! return SANE_STATUS_NO_MEM;
|
|
<BR>
|
|
!
|
|
<BR>
|
|
! full_name = mem + sizeof (*dev);
|
|
<BR>
|
|
! strcpy (full_name, be->name);
|
|
<BR>
|
|
! strcat (full_name, ":");
|
|
<BR>
|
|
! strcat (full_name, be_list[i]->name);
|
|
<BR>
|
|
|
|
<BR>
|
|
dev = (SANE_Device *) mem;
|
|
<BR>
|
|
dev->name = full_name;
|
|
<BR>
|
|
--- 637,683 ----
|
|
<BR>
|
|
{
|
|
<BR>
|
|
SANE_Device *dev;
|
|
<BR>
|
|
char *mem;
|
|
<BR>
|
|
+ struct alias *alias;
|
|
<BR>
|
|
|
|
<BR>
|
|
! for(alias = first_alias; alias != NULL; alias = alias->next)
|
|
<BR>
|
|
! {
|
|
<BR>
|
|
! len = strlen(be->name);
|
|
<BR>
|
|
! if( strlen(alias->oldname) <= len )
|
|
<BR>
|
|
! continue;
|
|
<BR>
|
|
! if( strncmp(alias->oldname, be->name, len) == 0
|
|
<BR>
|
|
! && alias->oldname[len] == ':'
|
|
<BR>
|
|
! && strcmp(&alias->oldname[len+1], be_list[i]->name) == 0 )
|
|
<BR>
|
|
! break;
|
|
<BR>
|
|
! }
|
|
<BR>
|
|
!
|
|
<BR>
|
|
! if( alias )
|
|
<BR>
|
|
! {
|
|
<BR>
|
|
! if( !alias->newname ) /* hidden device */
|
|
<BR>
|
|
! continue;
|
|
<BR>
|
|
!
|
|
<BR>
|
|
! len = strlen(alias->newname);
|
|
<BR>
|
|
! mem = malloc(sizeof(*dev) + len + 1);
|
|
<BR>
|
|
! if( !mem )
|
|
<BR>
|
|
! return SANE_STATUS_NO_MEM;
|
|
<BR>
|
|
!
|
|
<BR>
|
|
! full_name = mem + sizeof(*dev);
|
|
<BR>
|
|
! strcpy(full_name, alias->newname);
|
|
<BR>
|
|
! }
|
|
<BR>
|
|
! else
|
|
<BR>
|
|
! {
|
|
<BR>
|
|
! /* create a new device entry with a device name that is the
|
|
<BR>
|
|
! sum of the backend name a colon and the backend's device
|
|
<BR>
|
|
! name: */
|
|
<BR>
|
|
! len = strlen (be->name) + 1 + strlen (be_list[i]->name);
|
|
<BR>
|
|
! mem = malloc (sizeof (*dev) + len + 1);
|
|
<BR>
|
|
! if (!mem)
|
|
<BR>
|
|
! return SANE_STATUS_NO_MEM;
|
|
<BR>
|
|
!
|
|
<BR>
|
|
! full_name = mem + sizeof (*dev);
|
|
<BR>
|
|
! strcpy (full_name, be->name);
|
|
<BR>
|
|
! strcat (full_name, ":");
|
|
<BR>
|
|
! strcat (full_name, be_list[i]->name);
|
|
<BR>
|
|
! }
|
|
<BR>
|
|
|
|
<BR>
|
|
dev = (SANE_Device *) mem;
|
|
<BR>
|
|
dev->name = full_name;
|
|
<BR>
|
|
***************
|
|
<BR>
|
|
*** 557,562 ****
|
|
<BR>
|
|
--- 705,722 ----
|
|
<BR>
|
|
SANE_Handle *handle;
|
|
<BR>
|
|
struct backend *be;
|
|
<BR>
|
|
SANE_Status status;
|
|
<BR>
|
|
+ struct alias *alias;
|
|
<BR>
|
|
+
|
|
<BR>
|
|
+ for( alias = first_alias; alias != NULL; alias = alias->next )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ if( !alias->newname )
|
|
<BR>
|
|
+ continue;
|
|
<BR>
|
|
+ if( strcmp(alias->newname, full_name) == 0 )
|
|
<BR>
|
|
+ {
|
|
<BR>
|
|
+ full_name = alias->oldname;
|
|
<BR>
|
|
+ break;
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
+ }
|
|
<BR>
|
|
|
|
<BR>
|
|
dev_name = strchr (full_name, ':');
|
|
<BR>
|
|
if (dev_name)
|
|
<BR>
|
|
<P><P><P><PRE>
|
|
--
|
|
Source code, list archive, and docs: <A HREF="http://www.mostang.com/sane/">http://www.mostang.com/sane/</A>
|
|
To unsubscribe: echo unsubscribe sane-devel | mail <A HREF="mailto:majordomo@mostang.com?Subject=Re:%20dll%20backend:%20aliased%20&%20hidden%20device%20names&In-Reply-To=<m12Db71-000ILSC@petersfehn.Informatik.Uni-Oldenburg.DE>">majordomo@mostang.com</A>
|
|
</PRE>
|
|
<P><!-- body="end" -->
|
|
<HR NOSHADE>
|
|
<UL>
|
|
<!-- next="start" -->
|
|
<LI><STRONG>Next message:</STRONG> <A HREF="0252.html">jes@presto.med.upenn.edu: "Re: Semi OT: SCSI termination question"</A>
|
|
<LI><STRONG>Previous message:</STRONG> <A HREF="0250.html">Jonathan Buzzard: "Re: Update: Linux USB and Scanners"</A>
|
|
<!-- nextthread="start" -->
|
|
<!-- reply="end" -->
|
|
<LI><STRONG>Messages sorted by:</STRONG>
|
|
<A HREF="date.html#251">[ date ]</A>
|
|
<A HREF="index.html#251">[ thread ]</A>
|
|
<A HREF="subject.html#251">[ subject ]</A>
|
|
<A HREF="author.html#251">[ author ]</A>
|
|
</UL>
|
|
<!-- trailer="footer" -->
|
|
<HR NOSHADE>
|
|
<P>
|
|
<SMALL>
|
|
<EM>
|
|
This archive was generated by <A HREF="http://www.hypermail.org/">hypermail 2b29</A>
|
|
: <EM>Wed Jan 26 2000 - 14:39:38 PST</EM>
|
|
</EM>
|
|
</SMALL>
|
|
</BODY>
|
|
</HTML>
|