c94231f5661e4e757b54950a603ae66e593a1d3e
[easyphoto] / example.c
1 /**
2  * @file exmaple.c
3  * @author Rouslan V. Solomakhin
4  * @license GPL
5  */
6
7 #include "camera.h"
8
9 int main( int argc, char *argv[] )
10 {
11         photo_t context;
12   const char *file_name = "/home/user/MyDocs/Picture.jpg";
13  
14   if ( !photo_initialize( &context, &argc, &argv ) ) {
15     g_critical("Failed to initialize photo camera");
16     return EXIT_FAILURE;
17   }
18   
19   if ( argc >= 2 ) {
20     for ( int i = 1; i < argc; i++ ) {
21       g_message("Taking a photo %s...", argv[i]);
22       if ( !photo_take( &context, argv[i] ) ) {
23         g_critical("Failed to take a photo");
24         photo_destroy( &context );
25         return EXIT_FAILURE;
26       }
27     }
28   } else {
29     g_message("Taking a photo %s...", file_name);
30     if ( !photo_take( &context, file_name ) ) {
31       g_critical("Failed to take a photo");
32       photo_destroy( &context );
33       return EXIT_FAILURE;
34     }
35   }
36   
37   if ( !photo_destroy( &context ) ) {
38     g_critical("Failed to uninitialize photo camera");
39     return EXIT_FAILURE;
40   }
41   
42   return EXIT_SUCCESS;
43 }