~ubuntu-branches/ubuntu/wily/libimobiledevice/wily

« back to all changes in this revision

Viewing changes to tools/idevicescreenshot.c

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki, Matthias Niess, Timo Jyrinki
  • Date: 2014-03-14 08:44:15 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20140314084415-twglhjx6bqzmir8v
Tags: 1.1.5+git20140313.bafe6a9e-0ubuntu1
[ Matthias Niess ]
* Replace a duplicate 'backup' util man page with the one for 'crashreport'

[ Timo Jyrinki ]
* New upstream snapshot. (LP: #1207812)
* Drop patches include in the upstream snapshot:
  - debian/patches/CVE-2013-2142.patch
  - debian/patches/git_explicitly_cast_ssl_enabled.patch
* Drop the python patch, new upstream method seems to work:
  - debian/patches/09_use_python_config.patch
* Refreshed remaining patches:
  - debian/patches/01-libs.private.patch
  - debian/patches/02-fix-link-errors.patch
* Drop libimobiledevice-doc, the git does not include html documentation
* Updated libimobiledevice4.symbols 
* Add missing man page for the 'idevicename' util

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
        int result = -1;
41
41
        int i;
42
42
        const char *udid = NULL;
 
43
        char *filename = NULL;
43
44
 
44
45
        /* parse cmdline args */
45
46
        for (i = 1; i < argc; i++) {
60
61
                        print_usage(argc, argv);
61
62
                        return 0;
62
63
                }
 
64
                else if (argv[i][0] != '-' && !filename) {
 
65
                        filename = strdup(argv[i]);
 
66
                        continue;
 
67
                }
63
68
                else {
64
69
                        print_usage(argc, argv);
65
70
                        return 0;
88
93
                        printf("Could not connect to screenshotr!\n");
89
94
                } else {
90
95
                        char *imgdata = NULL;
91
 
                        char filename[36];
92
96
                        uint64_t imgsize = 0;
93
 
                        time_t now = time(NULL);
94
 
                        strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now));
 
97
                        if (!filename) {
 
98
                                time_t now = time(NULL);
 
99
                                filename = (char*)malloc(36);
 
100
                                strftime(filename, 36, "screenshot-%Y-%m-%d-%H-%M-%S.tiff", gmtime(&now));
 
101
                        }
95
102
                        if (screenshotr_take_screenshot(shotr, &imgdata, &imgsize) == SCREENSHOTR_E_SUCCESS) {
96
103
                                FILE *f = fopen(filename, "wb");
97
104
                                if (f) {
118
125
                lockdownd_service_descriptor_free(service);
119
126
 
120
127
        idevice_free(device);
 
128
        free(filename);
121
129
 
122
130
        return result;
123
131
}
124
132
 
125
133
void print_usage(int argc, char **argv)
126
134
{
127
 
        char *name = NULL;
 
135
        char *name = NULL;
128
136
 
129
 
        name = strrchr(argv[0], '/');
130
 
        printf("Usage: %s [OPTIONS]\n", (name ? name + 1: argv[0]));
131
 
        printf("Gets a screenshot from a device.\n");
132
 
        printf("The screenshot is saved as a TIFF image in the current directory.\n");
133
 
        printf("NOTE: A mounted developer disk image is required on the device, otherwise\n");
134
 
        printf("the screenshotr service is not available.\n\n");
135
 
        printf("  -d, --debug\t\tenable communication debugging\n");
136
 
        printf("  -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n");
137
 
        printf("  -h, --help\t\tprints usage information\n");
138
 
        printf("\n");
 
137
        name = strrchr(argv[0], '/');
 
138
        printf("Usage: %s [OPTIONS] [FILE]\n", (name ? name + 1: argv[0]));
 
139
        printf("Gets a screenshot from a device.\n");
 
140
        printf("The screenshot is saved as a TIFF image with the given FILE name,\n");
 
141
        printf("where the default name is \"screenshot-DATE.tiff\", e.g.:\n");
 
142
        printf("   ./screenshot-2013-12-31-23-59-59.tiff\n\n");
 
143
        printf("NOTE: A mounted developer disk image is required on the device, otherwise\n");
 
144
        printf("the screenshotr service is not available.\n\n");
 
145
        printf("  -d, --debug\t\tenable communication debugging\n");
 
146
        printf("  -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n");
 
147
        printf("  -h, --help\t\tprints usage information\n");
 
148
        printf("\n");
139
149
}