diff options
| author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2021-02-16 18:25:42 +0100 | 
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2021-02-16 18:25:42 +0100 | 
| commit | 64ddd1a4dfcefd11f662f5cf4bb05b590d901a97 (patch) | |
| tree | 4303648095deff998ae20c2393b56db527742ac9 /backend/escl/escl_devices.c | |
| parent | 5793a221e112fa49073de0137d6bfa750a61b0a1 (diff) | |
| parent | ecaaf250cb33ff61f37a7b441f2337584a655350 (diff) | |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'backend/escl/escl_devices.c')
| -rw-r--r-- | backend/escl/escl_devices.c | 31 | 
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"); | 
