5 #include <gphoto2/gphoto2-camera.h>
9 static void errordumper(GPLogLevel level, const char *domain, const char *format,
10 va_list args, void *data) {
11 vfprintf(stdout, format, args);
12 fprintf(stdout, "\n");
15 /* Set the owner of the first camera.
17 * This program can autodetect a single camera and then sets its
18 * owner to the string passed on the cmdline.
21 * gphoto2 --get-config ownername
22 * gphoto2 --set-config ownername="Owner Name"
25 int main(int argc, char **argv) {
31 context = sample_create_context (); /* see context.c */
33 gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
35 gp_camera_new (&camera);
37 /* This call will autodetect cameras, take the
38 * first one from the list and use it. It will ignore
39 * any others... See the *multi* examples on how to
40 * detect and use more than the first one.
42 ret = gp_camera_init (camera, context);
44 printf("No camera auto detected.\n");
45 gp_camera_free (camera);
49 ret = get_config_value_string (camera, "ownername", &owner, context);
51 printf ("Could not query owner.\n");
54 printf("Current owner: %s\n", owner);
56 ret = set_config_value_string (camera, "ownername", argv[1], context);
58 fprintf (stderr, "Failed to set camera owner to %s; %d\n", argv[1], ret);
60 printf("New owner: %s\n", argv[1]);
63 gp_camera_exit (camera, context);
64 gp_camera_free (camera);