Skip to content

Commit

Permalink
common: Move string_toupper() helper to utils and use it in ideviceba…
Browse files Browse the repository at this point in the history
…ckup tools
  • Loading branch information
FunkyM committed Oct 22, 2014
1 parent 067c7c6 commit 5753847
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
10 changes: 10 additions & 0 deletions common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ char *string_build_path(const char *elem, ...)
return out;
}

char *string_toupper(char* str)
{
char *res = strdup(str);
unsigned int i;
for (i = 0; i < strlen(res); i++) {
res[i] = toupper(res[i]);
}
return res;
}

static int get_rand(int min, int max)
{
int retval = (rand() % (max - min)) + min;
Expand Down
1 change: 1 addition & 0 deletions common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ char *stpcpy(char *s1, const char *s2);
#endif
char *string_concat(const char *str, ...);
char *string_build_path(const char *elem, ...);
char *string_toupper(char *str);
char *generate_uuid();

void buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length);
Expand Down
12 changes: 1 addition & 11 deletions tools/idevicebackup.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,6 @@ static void notify_cb(const char *notification, void *userdata)
}
}

static char *str_toupper(char* str)
{
char *res = strdup(str);
unsigned int i;
for (i = 0; i < strlen(res); i++) {
res[i] = toupper(res[i]);
}
return res;
}

static char* format_size_for_display(uint64_t size)
{
char buf[32];
Expand Down Expand Up @@ -295,7 +285,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid)
plist_dict_set_item(ret, "Target Identifier", plist_new_string(udid));

/* uppercase */
udid_uppercase = str_toupper((char*)udid);
udid_uppercase = string_toupper((char*)udid);
plist_dict_set_item(ret, "Unique Identifier", plist_new_string(udid_uppercase));
free(udid_uppercase);

Expand Down
12 changes: 1 addition & 11 deletions tools/idevicebackup2.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ static void mobilebackup_afc_get_file_contents(afc_client_t afc, const char *fil
afc_file_close(afc, f);
}

static char *str_toupper(char* str)
{
char *res = strdup(str);
unsigned int i;
for (i = 0; i < strlen(res); i++) {
res[i] = toupper(res[i]);
}
return res;
}

static int __mkdir(const char* path, int mode)
{
#ifdef WIN32
Expand Down Expand Up @@ -273,7 +263,7 @@ static plist_t mobilebackup_factory_info_plist_new(const char* udid, lockdownd_c
plist_dict_set_item(ret, "Target Type", plist_new_string("Device"));

/* uppercase */
udid_uppercase = str_toupper((char*)udid);
udid_uppercase = string_toupper((char*)udid);
plist_dict_set_item(ret, "Unique Identifier", plist_new_string(udid_uppercase));
free(udid_uppercase);

Expand Down

0 comments on commit 5753847

Please sign in to comment.