summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2015-01-28 01:27:59 +0100
committerGravatar Martin Szulecki2015-01-28 01:27:59 +0100
commit24ce2e27b47d3ad460680e02514f5bdbd4628724 (patch)
treeff174ebb7deab82d1f9c031d147e47e01bf47d3a /tools/idevicebackup2.c
parentc9d8013c1a6d69ef8b6024166629413e481e185d (diff)
downloadlibimobiledevice-24ce2e27b47d3ad460680e02514f5bdbd4628724.tar.gz
libimobiledevice-24ce2e27b47d3ad460680e02514f5bdbd4628724.tar.bz2
Remove trailing whitespace errors from all files
Diffstat (limited to 'tools/idevicebackup2.c')
-rw-r--r--tools/idevicebackup2.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index abc0efa..ead4dba 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -9,15 +9,15 @@
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version. 11 * version 2.1 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details. 16 * Lesser General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Lesser General Public 18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software 19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */ 21 */
22 22
23#include <stdio.h> 23#include <stdio.h>
@@ -142,7 +142,6 @@ static void mobilebackup_afc_get_file_contents(afc_client_t afc, const char *fil
142 uint32_t bread = 0; 142 uint32_t bread = 0;
143 afc_file_read(afc, f, buf+done, 65536, &bread); 143 afc_file_read(afc, f, buf+done, 65536, &bread);
144 if (bread > 0) { 144 if (bread > 0) {
145
146 } else { 145 } else {
147 break; 146 break;
148 } 147 }
@@ -172,7 +171,7 @@ static int mkdir_with_parents(const char *dir, int mode)
172 if (__mkdir(dir, mode) == 0) { 171 if (__mkdir(dir, mode) == 0) {
173 return 0; 172 return 0;
174 } else { 173 } else {
175 if (errno == EEXIST) return 0; 174 if (errno == EEXIST) return 0;
176 } 175 }
177 int res; 176 int res;
178 char *parent = strdup(dir); 177 char *parent = strdup(dir);
@@ -180,7 +179,7 @@ static int mkdir_with_parents(const char *dir, int mode)
180 if (parentdir) { 179 if (parentdir) {
181 res = mkdir_with_parents(parentdir, mode); 180 res = mkdir_with_parents(parentdir, mode);
182 } else { 181 } else {
183 res = -1; 182 res = -1;
184 } 183 }
185 free(parent); 184 free(parent);
186 if (res == 0) { 185 if (res == 0) {
@@ -590,7 +589,7 @@ leave:
590 } 589 }
591 char *errdesc = strerror(errcode); 590 char *errdesc = strerror(errcode);
592 mb2_multi_status_add_file_error(*errplist, path, errno_to_device_error(errcode), errdesc); 591 mb2_multi_status_add_file_error(*errplist, path, errno_to_device_error(errcode), errdesc);
593 592
594 length = strlen(errdesc); 593 length = strlen(errdesc);
595 nlen = htobe32(length+1); 594 nlen = htobe32(length+1);
596 memcpy(buf, &nlen, 4); 595 memcpy(buf, &nlen, 4);
@@ -616,7 +615,7 @@ leave_proto_err:
616 615
617static void mb2_handle_send_files(mobilebackup2_client_t mobilebackup2, plist_t message, const char *backup_dir) 616static void mb2_handle_send_files(mobilebackup2_client_t mobilebackup2, plist_t message, const char *backup_dir)
618{ 617{
619 uint32_t cnt; 618 uint32_t cnt;
620 uint32_t i = 0; 619 uint32_t i = 0;
621 uint32_t sent; 620 uint32_t sent;
622 plist_t errplist = NULL; 621 plist_t errplist = NULL;
@@ -1077,15 +1076,15 @@ static void get_hidden_input(char *buf, int maxlen)
1077static char* ask_for_password(const char* msg, int type_again) 1076static char* ask_for_password(const char* msg, int type_again)
1078{ 1077{
1079 char pwbuf[256]; 1078 char pwbuf[256];
1080 1079
1081 fprintf(stderr, "%s: ", msg); 1080 fprintf(stderr, "%s: ", msg);
1082 fflush(stderr); 1081 fflush(stderr);
1083 get_hidden_input(pwbuf, 256); 1082 get_hidden_input(pwbuf, 256);
1084 fputc('\n', stderr); 1083 fputc('\n', stderr);
1085 1084
1086 if (type_again) { 1085 if (type_again) {
1087 char pwrep[256]; 1086 char pwrep[256];
1088 1087
1089 fprintf(stderr, "%s (repeat): ", msg); 1088 fprintf(stderr, "%s (repeat): ", msg);
1090 fflush(stderr); 1089 fflush(stderr);
1091 get_hidden_input(pwrep, 256); 1090 get_hidden_input(pwrep, 256);
@@ -1168,7 +1167,7 @@ int main(int argc, char *argv[])
1168 /* we need to exit cleanly on running backups and restores or we cause havok */ 1167 /* we need to exit cleanly on running backups and restores or we cause havok */
1169 signal(SIGINT, clean_exit); 1168 signal(SIGINT, clean_exit);
1170 signal(SIGTERM, clean_exit); 1169 signal(SIGTERM, clean_exit);
1171#ifndef WIN32 1170#ifndef WIN32
1172 signal(SIGQUIT, clean_exit); 1171 signal(SIGQUIT, clean_exit);
1173 signal(SIGPIPE, SIG_IGN); 1172 signal(SIGPIPE, SIG_IGN);
1174#endif 1173#endif
@@ -1274,7 +1273,7 @@ int main(int argc, char *argv[])
1274 if (!argv[i]) { 1273 if (!argv[i]) {
1275 printf("No argument given for encryption command; requires either 'on' or 'off'.\n"); 1274 printf("No argument given for encryption command; requires either 'on' or 'off'.\n");
1276 print_usage(argc, argv); 1275 print_usage(argc, argv);
1277 return -1; 1276 return -1;
1278 } 1277 }
1279 if (!strcmp(argv[i], "on")) { 1278 if (!strcmp(argv[i], "on")) {
1280 cmd_flags |= CMD_FLAG_ENCRYPTION_ENABLE; 1279 cmd_flags |= CMD_FLAG_ENCRYPTION_ENABLE;
@@ -1291,7 +1290,7 @@ int main(int argc, char *argv[])
1291 if (backup_password) { 1290 if (backup_password) {
1292 free(backup_password); 1291 free(backup_password);
1293 backup_password = NULL; 1292 backup_password = NULL;
1294 } 1293 }
1295 i++; 1294 i++;
1296 if (argv[i]) { 1295 if (argv[i]) {
1297 if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) { 1296 if (cmd_flags & CMD_FLAG_ENCRYPTION_ENABLE) {
@@ -1304,7 +1303,7 @@ int main(int argc, char *argv[])
1304 } 1303 }
1305 else if (!strcmp(argv[i], "changepw")) { 1304 else if (!strcmp(argv[i], "changepw")) {
1306 cmd = CMD_CHANGEPW; 1305 cmd = CMD_CHANGEPW;
1307 cmd_flags |= CMD_FLAG_ENCRYPTION_CHANGEPW; 1306 cmd_flags |= CMD_FLAG_ENCRYPTION_CHANGEPW;
1308 // check if passwords were given on command line 1307 // check if passwords were given on command line
1309 if (newpw) { 1308 if (newpw) {
1310 free(newpw); 1309 free(newpw);
@@ -1313,7 +1312,7 @@ int main(int argc, char *argv[])
1313 if (backup_password) { 1312 if (backup_password) {
1314 free(backup_password); 1313 free(backup_password);
1315 backup_password = NULL; 1314 backup_password = NULL;
1316 } 1315 }
1317 i++; 1316 i++;
1318 if (argv[i]) { 1317 if (argv[i]) {
1319 backup_password = strdup(argv[i]); 1318 backup_password = strdup(argv[i]);
@@ -1382,7 +1381,7 @@ int main(int argc, char *argv[])
1382 } 1381 }
1383 1382
1384 uint8_t is_encrypted = 0; 1383 uint8_t is_encrypted = 0;
1385 char *info_path = NULL; 1384 char *info_path = NULL;
1386 if (cmd == CMD_CHANGEPW) { 1385 if (cmd == CMD_CHANGEPW) {
1387 if (!interactive_mode && !backup_password && !newpw) { 1386 if (!interactive_mode && !backup_password && !newpw) {
1388 idevice_free(device); 1387 idevice_free(device);
@@ -1609,7 +1608,7 @@ checkpoint:
1609 } 1608 }
1610 1609
1611 /* TODO: check domain com.apple.mobile.backup key RequiresEncrypt and WillEncrypt with lockdown */ 1610 /* TODO: check domain com.apple.mobile.backup key RequiresEncrypt and WillEncrypt with lockdown */
1612 /* TODO: verify battery on AC enough battery remaining */ 1611 /* TODO: verify battery on AC enough battery remaining */
1613 1612
1614 /* re-create Info.plist (Device infos, IC-Info.sidb, photos, app_ids, iTunesPrefs) */ 1613 /* re-create Info.plist (Device infos, IC-Info.sidb, photos, app_ids, iTunesPrefs) */
1615 if (info_plist) { 1614 if (info_plist) {
@@ -1776,7 +1775,7 @@ checkpoint:
1776 if (newpw) { 1775 if (newpw) {
1777 free(newpw); 1776 free(newpw);
1778 newpw = NULL; 1777 newpw = NULL;
1779 } 1778 }
1780 if (backup_password) { 1779 if (backup_password) {
1781 free(backup_password); 1780 free(backup_password);
1782 backup_password = NULL; 1781 backup_password = NULL;
@@ -2057,7 +2056,6 @@ checkpoint:
2057 printf("%s", str); 2056 printf("%s", str);
2058 free(str); 2057 free(str);
2059 } 2058 }
2060
2061 break; 2059 break;
2062 } 2060 }
2063 2061
@@ -2134,7 +2132,7 @@ files_out:
2134 } 2132 }
2135 } else if (cmd_flags & CMD_FLAG_ENCRYPTION_DISABLE) { 2133 } else if (cmd_flags & CMD_FLAG_ENCRYPTION_DISABLE) {
2136 if (operation_ok) { 2134 if (operation_ok) {
2137 PRINT_VERBOSE(1, "Backup encryption has been disabled successfully.\n"); 2135 PRINT_VERBOSE(1, "Backup encryption has been disabled successfully.\n");
2138 } else { 2136 } else {
2139 PRINT_VERBOSE(1, "Could not disable backup encryption.\n"); 2137 PRINT_VERBOSE(1, "Could not disable backup encryption.\n");
2140 } 2138 }
@@ -2154,7 +2152,6 @@ files_out:
2154 } else { 2152 } else {
2155 PRINT_VERBOSE(1, "Restore Failed (Error Code %d).\n", -result_code); 2153 PRINT_VERBOSE(1, "Restore Failed (Error Code %d).\n", -result_code);
2156 } 2154 }
2157
2158 break; 2155 break;
2159 case CMD_INFO: 2156 case CMD_INFO:
2160 case CMD_LIST: 2157 case CMD_LIST: