

/*
    unicap
    Copyright (C) 2004  Arne Caspari

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/**
   device_list.c

   Sample program demonstrating the basic usage of the unicap library

   
   This example opens all devices found by the unicap library and outputs their name, 
   supported properties and supported formats to stdout. 

 **/


#include <stdlib.h>
#include <stdio.h>
#include <unicap.h>
#include <status.h>

int main( int argc, char **argv )
{
   unicap_handle_t handle;
   unicap_device_t device;

   int i = 0;

   printf( "\n\nUnicap device list:\n\n" );
   
   while( SUCCESS( unicap_enumerate_devices( NULL, &device, i++ ) ) )
   {
       unicap_property_t property;
       unicap_format_t format;
       int property_count;
       int format_count;
       int j;

       if( !SUCCESS( unicap_open( &handle, &device ) ) )
       {
           fprintf( stderr, "Failed to open: %s\n", device.identifier );
           continue;
       }
       
       unicap_reenumerate_properties( handle, &property_count );
       unicap_reenumerate_formats( handle, &format_count );
       
       printf( "Device: %s\n", device.identifier );

       printf( "\tProperties[%d]:\n", property_count );
       
       for( j = 0; SUCCESS( unicap_enumerate_properties( handle, NULL, &property, j ) ); j++ )
       {
           printf( "\t\t%s\n", property.identifier );
       }
       
       printf( "\tFormats[%d]:\n", format_count );

       for( j = 0; SUCCESS( unicap_enumerate_formats( handle, NULL, &format, j ) ); j++ )
       {
           printf( "\t\t%s\n", format.identifier );
       }
       
       unicap_close( handle );
   }
   
   return 0;
}

       



