Sane API problem: multiple sane_init calls

From: mh (moloch@nikocity.de)
Date: Fri Jun 30 2000 - 12:33:41 PDT

  • Next message: Jochen Eisinger: "Re: bug in saned"

    Hi,
    since I'm new to this list, I dare to ask a dump question:
    I'm trying to make use of the Sane API from within a C++ program to write a
    little frontend for my scanner.
    My problem is that I'm unable to make a call to sane_init for more then one
    time. Whenever I call sane_init a second time my app segfaults.
    Please have a look at the following code:
    (and sorry, if this isn't a Sane problem at all)

    ////////////////////////////////////////////////////
    // tested with SuSE 6.4, Kernel 2.2.14
    //gcc/g++ 2.95.2
    //Sane 1.0.2
    //backend for plustek parallel port scanner version 0.27
    //dynamically linked
    //Scanner Plustek OpticPro 600P
    #include <stdio.h>
    extern "C"
    {
    #include <sane/sane.h>
    #include <sane/sanei.h>
    #include <sane/saneopts.h>
    #include <sane/config.h>
    }

    int main(int argc, char *argv[])
    {
      const SANE_Device** device_list ;
      const SANE_Device** device_list2 ;
      int i;
      SANE_Status status;
      status=sane_init(0,0);
      if(status==SANE_STATUS_GOOD)
      {
        status=sane_get_devices(&device_list,SANE_FALSE);
        if(status==SANE_STATUS_GOOD)
        {
          for (i = 0; device_list[i]; ++i)
                 printf("%s %s\n",device_list[i]->vendor,device_list[i]->model);
        }
      }
      sane_exit();
      status=sane_init(0,0);
      if(status==SANE_STATUS_GOOD)
      {
        status=sane_get_devices(&device_list2,SANE_FALSE);
        if(status==SANE_STATUS_GOOD)
        {
          for (i = 0; device_list2[i]; ++i)
                 printf("%s %s\n",device_list2[i]->vendor,device_list2[i]->model);
        }
      }
      sane_exit();
      return 0;
    }

    The output on the command line:
    Plustek 600P Vers = 0.0
    Noname PNM file reader
    Noname PNM file reader
    Speicherzugriffsfehler (segfault)

    Program received signal SIGSEGV, Segmentation fault.
    0x400effa4 in strcat () at ../sysdeps/generic/strcat.c:51
    51 ../sysdeps/generic/strcat.c: Datei oder Verzeichnis nicht gefunden.
    (gdb) bt
    #0 0x400effa4 in strcat () at ../sysdeps/generic/strcat.c:51
    #1 0x4002201e in sane_dll_get_devices () at dll.c:472
    #2 0x40022733 in sane_get_devices () at dll-s.c:35
    #3 0x80486f2 in main ()
    #4 0x400b3a5e in __libc_start_main () at ../sysdeps/generic/libc-start.c:93

    What does the debugger output mean: ..../strcat.c:51 "file or folder not found"?
    (There's no strcat.c on my system at all)
      
    Can someone explain this please?
    Thanks a lot,
    Michael

    BTW Sane is *cool*.
    Now there's almost no reason left to boot Windoze.

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



    This archive was generated by hypermail 2b29 : Fri Jun 30 2000 - 13:40:56 PDT