summaryrefslogtreecommitdiff
path: root/backend/escl/escl_devices.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2021-05-18 07:43:35 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2021-05-18 07:43:35 +0200
commit9f8889f928ce86ba4a78659d378c6ba29bc9f735 (patch)
treec9567cb0d015b68ce3da8d03472b6443f1cb1ca9 /backend/escl/escl_devices.c
parent446e9454b8cbe5b689149415d11d36e88442ca88 (diff)
parent154785ab2d5df7ddc8c2cf813b773c340e5e2aea (diff)
Merge branch 'release/debian/1.0.32-1'debian/1.0.32-1
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");