summaryrefslogtreecommitdiff
path: root/backend/escl/escl_devices.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2021-02-16 18:24:19 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2021-02-16 18:24:19 +0100
commit351b7328520c16730ceb46e5acae16038c42185e (patch)
treefae21fd5c94f3c3ed0202a95c9ada705482e647b /backend/escl/escl_devices.c
parentad38bc6ecb80ddeb562841b33258dd53659b1da6 (diff)
New upstream version 1.0.32upstream/1.0.32
Diffstat (limited to 'backend/escl/escl_devices.c')
-rw-r--r--backend/escl/escl_devices.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/backend/escl/escl_devices.c b/backend/escl/escl_devices.c
index 7ecbe31..3ca28de 100644
--- a/backend/escl/escl_devices.c
+++ b/backend/escl/escl_devices.c
@@ -16,8 +16,8 @@
for more details.
You should have received a copy of the GNU General Public License
- along with sane; see the file COPYING. If not, write to the Free
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with sane; see the file COPYING.
+ If not, see <https://www.gnu.org/licenses/>.
This file implements a SANE backend for eSCL scanners. */
@@ -38,6 +38,7 @@
#include "../include/sane/sanei.h"
static AvahiSimplePoll *simple_poll = NULL;
+static int count_finish = 0;
/**
* \fn static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED
@@ -62,6 +63,9 @@ resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interfac
void __sane_unused__ *userdata)
{
char a[AVAHI_ADDRESS_STR_MAX], *t;
+ const char *is;
+ const char *uuid;
+ AvahiStringList *s;
assert(r);
switch (event) {
case AVAHI_RESOLVER_FAILURE:
@@ -69,8 +73,19 @@ resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interfac
case AVAHI_RESOLVER_FOUND:
avahi_address_snprint(a, sizeof(a), address);
t = avahi_string_list_to_string(txt);
- if (strstr(t, "\"rs=eSCL\"") || strstr(t, "\"rs=/eSCL\""))
- escl_device_add(port, name, a, (char*)type);
+ if (strstr(t, "\"rs=eSCL\"") || strstr(t, "\"rs=/eSCL\"")) {
+ s = avahi_string_list_find(txt, "is");
+ if (s && s->size > 3)
+ is = (const char*)s->text + 3;
+ else
+ is = (const char*)NULL;
+ s = avahi_string_list_find(txt, "uuid");
+ if (s && s->size > 5)
+ uuid = (const char*)s->text + 5;
+ else
+ uuid = (const char*)NULL;
+ escl_device_add(port, name, a, is, uuid, (char*)type);
+ }
}
}
@@ -107,7 +122,11 @@ browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface,
case AVAHI_BROWSER_ALL_FOR_NOW:
case AVAHI_BROWSER_CACHE_EXHAUSTED:
if (event != AVAHI_BROWSER_CACHE_EXHAUSTED)
- avahi_simple_poll_quit(simple_poll);
+ {
+ count_finish++;
+ if (count_finish == 2)
+ avahi_simple_poll_quit(simple_poll);
+ }
break;
}
}
@@ -143,6 +162,8 @@ escl_devices(SANE_Status *status)
AvahiServiceBrowser *sb = NULL;
int error;
+ count_finish = 0;
+
*status = SANE_STATUS_GOOD;
if (!(simple_poll = avahi_simple_poll_new())) {
DBG( 1, "Failed to create simple poll object.\n");