summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-03-13 19:56:00 +0100
committerGravatar Martin Szulecki2010-03-13 19:56:00 +0100
commitb6baa1c7d3a0f9e254cd3ed9d47b0fbdc918ce9a (patch)
tree6fbbc0f162994c35d2a8c252f424becf2baf895a
parent1ab0490c9db82f8aa05956b53a799f73d422d52f (diff)
downloadlibimobiledevice-b6baa1c7d3a0f9e254cd3ed9d47b0fbdc918ce9a.tar.gz
libimobiledevice-b6baa1c7d3a0f9e254cd3ed9d47b0fbdc918ce9a.tar.bz2
Use current date and time in filename of screenshot tool
-rw-r--r--tools/idevicescreenshot.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index ca4454c..1604198 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -2,6 +2,7 @@
2#include <string.h> 2#include <string.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#include <errno.h> 4#include <errno.h>
5#include <time.h>
5 6
6#include <libimobiledevice/libimobiledevice.h> 7#include <libimobiledevice/libimobiledevice.h>
7#include <libimobiledevice/lockdown.h> 8#include <libimobiledevice/lockdown.h>
@@ -68,19 +69,22 @@ int main(int argc, char **argv)
68 printf("Could not connect to screenshotr!\n"); 69 printf("Could not connect to screenshotr!\n");
69 } else { 70 } else {
70 char *imgdata = NULL; 71 char *imgdata = NULL;
72 char filename[36];
71 uint64_t imgsize = 0; 73 uint64_t imgsize = 0;
74 time_t now = time(NULL);
75 strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now));
72 if (screenshotr_take_screenshot(shotr, &imgdata, &imgsize) == SCREENSHOTR_E_SUCCESS) { 76 if (screenshotr_take_screenshot(shotr, &imgdata, &imgsize) == SCREENSHOTR_E_SUCCESS) {
73 FILE *f = fopen("screenshot.tiff", "w"); 77 FILE *f = fopen(filename, "w");
74 if (f) { 78 if (f) {
75 if (fwrite(imgdata, 1, (size_t)imgsize, f) == (size_t)imgsize) { 79 if (fwrite(imgdata, 1, (size_t)imgsize, f) == (size_t)imgsize) {
76 printf("Screenshot saved to screenshot.tiff\n"); 80 printf("Screenshot saved to %s\n", filename);
77 result = 0; 81 result = 0;
78 } else { 82 } else {
79 printf("Could not save screenshot to file!\n"); 83 printf("Could not save screenshot to file %s!\n", filename);
80 } 84 }
81 fclose(f); 85 fclose(f);
82 } else { 86 } else {
83 printf("Could not open screenshot.tiff for writing: %s\n", strerror(errno)); 87 printf("Could not open %s for writing: %s\n", filename, strerror(errno));
84 } 88 }
85 } else { 89 } else {
86 printf("Could not get screenshot!\n"); 90 printf("Could not get screenshot!\n");
@@ -102,8 +106,9 @@ void print_usage(int argc, char **argv)
102 name = strrchr(argv[0], '/'); 106 name = strrchr(argv[0], '/');
103 printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0])); 107 printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0]));
104 printf("Gets a screenshot from the connected iPhone/iPod Touch.\n"); 108 printf("Gets a screenshot from the connected iPhone/iPod Touch.\n");
105 printf("NOTE: A mounted developer disk image is required on the device, otherwise\n"); 109 printf("The screenshot is saved as a TIFF image in the current directory.\n");
106 printf(" the screenshotr service is not available.\n\n"); 110 printf("NOTE: A mounted developer disk image is required on the device, otherwise\n");
111 printf("the screenshotr service is not available.\n\n");
107 printf(" -d, --debug\t\tenable communication debugging\n"); 112 printf(" -d, --debug\t\tenable communication debugging\n");
108 printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); 113 printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n");
109 printf(" -h, --help\t\tprints usage information\n"); 114 printf(" -h, --help\t\tprints usage information\n");