// Zeigt alle Scanner mit Hilfe von LockScannerList() an


#include "devices/scanner.h"
#include "proto/scannerdevice_protos.h"


char *typstring[]={"Unbekannt","Flachbett","Handyscanner","Video","Fotokamera"};


main()
{
  int err;
  struct IOScanRequest *req;
  struct MsgPort *port;
  struct Library *ScannerBase;
  struct List *list;
  struct ScannerInfo *si;
  int i;

  port=CreateMsgPort();
  req=CreateIORequest(port,sizeof(struct IOScanRequest));

  err=OpenDevice("scanner.device",0,(struct IORequest *)req,0);

  if(err==0)
   {
    ScannerBase=(struct Library *)req->Req.io_Device;
    list=LockScannerList();

    for(si=(struct ScannerInfo *)list->lh_Head; si->Node.ln_Succ; si=(struct ScannerInfo *)si->Node.ln_Succ)
     {
      printf("Scannername: %s\n",si->Node.ln_Name);
      printf("  ScannerID: %d\n",si->ScannerID);
      printf("        Typ: %s\n",typstring[si->Type]);
      printf("Eigenschaften:\n");
      if(si->Flags&SCANIF_SINGLEPASS)   printf("      - Singolapassata\n");
      if(si->Flags&SCANIF_TRIPLEPASS)   printf("      - Triplapassata\n");
      if(si->Flags&SCANIF_SHEETFEEDER)  printf("      - Aliment.Fogli\n");
      if(si->Flags&SCANIF_TRANSPARENCY) printf("      - Aliment.Lucidi\n");
      printf("Max. Breite: ");
      if(si->MaxWidth==-1)  printf("(unendlich)\n");
      else                  printf("%d,%d mm\n",si->MaxWidth/1000,si->MaxWidth%1000);
      printf("Max. Höhe  : ");
      if(si->MaxHeight==-1) printf("(unendlich)\n");
      else                  printf("%d,%d mm\n",si->MaxHeight/1000,si->MaxHeight%1000);
      printf("Verfügbare Scanmodi:\n");
      for(i=0; si->Scanmodes[i]!=0; i++)
        printf("      - %s, %d Bit %s\n",si->Scanmodes[i]&SCMF_COLOR ? "Colore":"BiancoNero", si->Scanmodes[i]&SCMF_DEPTH, si->Scanmodes[i]&SCMF_HT ? "(MezziToni)":"");
      printf("\n");
     }

    UnlockScannerList();
    CloseDevice((struct IORequest *)req);
   }

  DeleteIORequest((struct IORequest *)req);
  DeleteMsgPort(port);
}
