summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2016-10-11 09:20:22 +0200
committerMarcus Meissner <marcus@jet.franken.de>2016-10-11 09:20:22 +0200
commitfe935d45f29cfda73560c5b2152e40238f2f02c1 (patch)
tree5d0c3cbe3a6eeb56c7d269217e49762421a99437 /examples
parent4cb1c943f345a5e0c6a0c41ac0ebe07d0a12a9ef (diff)
downloadlibgphoto2-fe935d45f29cfda73560c5b2152e40238f2f02c1.tar.gz
fixed reading configuration
better progress output
Diffstat (limited to 'examples')
-rw-r--r--examples/sample-photobooth.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/examples/sample-photobooth.c b/examples/sample-photobooth.c
index 7df1e26df..43a5bb259 100644
--- a/examples/sample-photobooth.c
+++ b/examples/sample-photobooth.c
@@ -113,11 +113,17 @@ main(int argc, char **argv) {
if (capture_now) {
capture_now = 0;
sprintf(output_file, "image-%04d.jpg", capturecnt++);
- capture_to_file(camera, context, output_file);
+ retval = capture_to_file(camera, context, output_file);
+ if (retval == GP_OK)
+ fprintf (stderr, "captured to %s\n", output_file);
}
/*
* Read configuration changes from "config.txt".
+ * Expected are key=value pairs where value is the value seen in "--get-config key", e.g.
+ * iso=Auto
+ * iso=200
+ * shutterspeed=1/200
*/
if (read_config) {
FILE *config;
@@ -129,6 +135,14 @@ main(int argc, char **argv) {
while (fgets (buf, sizeof(buf), config)) {
char *s;
+ /* kill linefeeds */
+ s = strchr(buf,'\r');
+ if (s)
+ *s=0;
+ s = strchr(buf,'\n');
+ if (s)
+ *s=0;
+
s = strchr(buf,'=');
if (!s) continue;
@@ -136,6 +150,8 @@ main(int argc, char **argv) {
retval = set_config_value_string (camera, buf, s+1, context);
if (retval < GP_OK)
fprintf (stderr, "setting configuration '%s' to '%s' failed with %d.\n", buf, s+1, retval);
+ else
+ fprintf (stderr, "changed configuration '%s' to '%s'\n", buf, s+1);
}
fclose (config);
}
@@ -179,8 +195,6 @@ main(int argc, char **argv) {
char *t;
path = (CameraFilePath*)evtdata;
- printf("File added on the camera: %s/%s\n", path->folder, path->name);
-
t = strrchr (path->name, '.');
if (t && (strlen(t+1) == 3)) {
sprintf(output_file, "image-%04d.%s", capturecnt++, t+1);
@@ -196,6 +210,7 @@ main(int argc, char **argv) {
retval = gp_camera_file_delete(camera, path->folder, path->name, context);
gp_file_free(file);
free (evtdata);
+ fprintf (stderr, "saved to %s\n", output_file);
break;
}
case GP_EVENT_FOLDER_ADDED: