summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGravatar Todd Wright2014-03-10 16:08:31 -0400
committerGravatar Martin Szulecki2014-03-12 20:13:17 +0100
commitfb4b91d7916e2b63b323fe98e1b1449d077ab469 (patch)
tree189d4210fe6c91e042124d23c3a36e3e1191af87 /tools
parentae06fef34f66c9e6c32181568a84b5f0ee7e761b (diff)
downloadlibimobiledevice-fb4b91d7916e2b63b323fe98e1b1449d077ab469.tar.gz
libimobiledevice-fb4b91d7916e2b63b323fe98e1b1449d077ab469.tar.bz2
idevicescreenshot: Allow user-specified output filename
Signed-off-by: Martin Szulecki <m.szulecki@libimobiledevice.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/idevicescreenshot.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/idevicescreenshot.c b/tools/idevicescreenshot.c
index 8f5fcaf..486265e 100644
--- a/tools/idevicescreenshot.c
+++ b/tools/idevicescreenshot.c
@@ -40,6 +40,7 @@ int main(int argc, char **argv)
int result = -1;
int i;
const char *udid = NULL;
+ char *filename = NULL;
/* parse cmdline args */
for (i = 1; i < argc; i++) {
@@ -60,6 +61,10 @@ int main(int argc, char **argv)
print_usage(argc, argv);
return 0;
}
+ else if (argv[i][0] != '-' && !filename) {
+ filename = strdup(argv[i]);
+ continue;
+ }
else {
print_usage(argc, argv);
return 0;
@@ -88,10 +93,12 @@ int main(int argc, char **argv)
printf("Could not connect to screenshotr!\n");
} else {
char *imgdata = NULL;
- char filename[36];
uint64_t imgsize = 0;
- time_t now = time(NULL);
- strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now));
+ if (!filename) {
+ time_t now = time(NULL);
+ filename = (char*)malloc(36);
+ strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now));
+ }
if (screenshotr_take_screenshot(shotr, &imgdata, &imgsize) == SCREENSHOTR_E_SUCCESS) {
FILE *f = fopen(filename, "wb");
if (f) {
@@ -118,6 +125,7 @@ int main(int argc, char **argv)
lockdownd_service_descriptor_free(service);
idevice_free(device);
+ free(filename);
return result;
}
@@ -127,9 +135,11 @@ void print_usage(int argc, char **argv)
char *name = NULL;
name = strrchr(argv[0], '/');
- printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0]));
+ printf("Usage: %s [OPTIONS] [FILE]\n", (name ? name + 1: argv[0]));
printf("Gets a screenshot from a device.\n");
- printf("The screenshot is saved as a TIFF image in the current directory.\n");
+ printf("The screenshot is saved as a TIFF image with the given FILE name,\n");
+ printf("where the default name is \"screenshot-DATE.tiff\", e.g.:\n");
+ printf(" ./screenshot-2013-12-31-23-59-59.tiff\n\n");
printf("NOTE: A mounted developer disk image is required on the device, otherwise\n");
printf("the screenshotr service is not available.\n\n");
printf(" -d, --debug\t\tenable communication debugging\n");