# Avoid duplicate net devices

Petter Reinholdtsen (pere@hungry.com)
Mon, 19 Apr 1999 13:55:53 +0200

- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Petter Reinholdtsen: "Sane 1.01pre5 works (HP/UX 10.20, Irix 6.5 and RedHat Linux 5.2)"
- Previous message: Petter Reinholdtsen: "Artec URL patch for sane 1.01pre5"

I finally made SANE 1.01pre5 work on SGI Irix. No bugs, it just
happends to read net.conf from current directory, not where the
correct one was installed with the host list... Stupid me... :-)

Anyway. While testing, I discovered that the net backend accepts
duplicate hosts, and calls the same host multiple times. Here is a
patch to avoid that.

diff -ru src-pre1.0.1r5/backend/net.c src-pre1.0.1r5-sgi4i6/backend/net.c
--- src-pre1.0.1r5/backend/net.c Sat Apr 3 06:43:01 1999
+++ src-pre1.0.1r5-sgi4i6/backend/net.c Mon Apr 19 13:50:43 1999
@@ -84,6 +84,15 @@
static Net_Scanner *first_handle;
static int saned_port;

+static SANE_Bool
+device_already_in_list(Net_Device *current, SANE_String_Const host)
+{
+ for ( ; NULL != current; current = current->next )
+ if (0 == strcasecmp(host, current->name) )
+ return SANE_TRUE;
+ return SANE_FALSE;
+}
+
static SANE_Status
add_device (const char *name, Net_Device **ndp)
{
@@ -91,6 +100,11 @@
Net_Device *nd;

DBG(1, "adding backend %s\n", name);
+
+ /* Avoid adding the same device more then once */
+ if (device_already_in_list(first_device, name)) {
+ return SANE_STATUS_GOOD;
+ }

he = gethostbyname (name);
if (!he)

This change is almost identical to the similar snapscan patch.

    --
    ##>  Petter Reinholdtsen <##    | pere@td.org.uit.no
     O-  <SCRIPT Language="Javascript">window.close()</SCRIPT>
    http://www.hungry.com/~pere/    | Go Mozilla, go! Go!

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

     Next message: Petter Reinholdtsen: "Sane 1.01pre5 works (HP/UX 10.20, Irix 6.5 and RedHat Linux 5.2)"
     Previous message: Petter Reinholdtsen: "Artec URL patch for sane 1.01pre5"