diff options
author | Dees_Troy <dees_troy@teamw.in> | 2012-09-27 16:09:41 +0200 |
---|---|---|
committer | Dees_Troy <dees_troy@teamw.in> | 2012-09-27 16:40:03 +0200 |
commit | c9ff7a341b03b3013eca57c7554417b623ab6bb0 (patch) | |
tree | e8cca26407ec35a3f31823f3bd77c861c51de347 /extra-functions.c | |
parent | Port reboot functions to C++ (diff) | |
download | android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.tar android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.tar.gz android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.tar.bz2 android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.tar.lz android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.tar.xz android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.tar.zst android_bootable_recovery-c9ff7a341b03b3013eca57c7554417b623ab6bb0.zip |
Diffstat (limited to 'extra-functions.c')
-rw-r--r-- | extra-functions.c | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/extra-functions.c b/extra-functions.c index f202aff33..3735472a3 100644 --- a/extra-functions.c +++ b/extra-functions.c @@ -55,51 +55,3 @@ void run_script(const char *str1, const char *str2, const char *str3, const char } } -int check_backup_name(int show_error) { - // Check the backup name to ensure that it is the correct size and contains only valid characters - // and that a backup with that name doesn't already exist - char backup_name[MAX_BACKUP_NAME_LEN]; - char backup_loc[255], tw_image_dir[255]; - int copy_size = strlen(DataManager_GetStrValue(TW_BACKUP_NAME)); - int index, cur_char; - struct stat st; - - // Check size - if (copy_size > MAX_BACKUP_NAME_LEN) { - if (show_error) - LOGE("Backup name is too long.\n"); - return -2; - } - - // Check characters - strncpy(backup_name, DataManager_GetStrValue(TW_BACKUP_NAME), copy_size); - if (strcmp(backup_name, "0") == 0) - return 0; // A "0" (zero) means to use the current timestamp for the backup name - for (index=0; index<copy_size; index++) { - cur_char = (int)backup_name[index]; - if (cur_char == 32 || (cur_char >= 48 && cur_char <= 57) || (cur_char >= 65 && cur_char <= 91) || cur_char == 93 || cur_char == 95 || (cur_char >= 97 && cur_char <= 123) || cur_char == 125 || cur_char == 45 || cur_char == 46) { - // These are valid characters - // Numbers - // Upper case letters - // Lower case letters - // Space - // and -_.{}[] - } else { - if (show_error) - LOGE("Backup name '%s' contains invalid character: '%c'\n", backup_name, (char)cur_char); - return -3; - } - } - - // Check to make sure that a backup with this name doesn't already exist - strcpy(backup_loc, DataManager_GetStrValue(TW_BACKUPS_FOLDER_VAR)); - sprintf(tw_image_dir,"%s/%s/.", backup_loc, backup_name); - if (stat(tw_image_dir, &st) == 0) { - if (show_error) - LOGE("A backup with this name already exists.\n"); - return -4; - } - - // No problems found, return 0 - return 0; -} |