CLI: Use printf return to compute string size instead of hardcoded values
This commit is contained in:
		@@ -81,19 +81,19 @@ static void signal_handler(int signum)
 | 
			
		||||
 | 
			
		||||
static void display_password(char* password, int time)
 | 
			
		||||
{
 | 
			
		||||
    int length;
 | 
			
		||||
    int print_len = 0;
 | 
			
		||||
 | 
			
		||||
    for (; time && !s_stop_display; time--)
 | 
			
		||||
    {
 | 
			
		||||
        printf("\r(%02d) Password found: %s", time, password);
 | 
			
		||||
        print_len = printf("\r(%02d) Password found: %s", time, password);
 | 
			
		||||
        fflush(stdout);
 | 
			
		||||
        sleep(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Clear line
 | 
			
		||||
    print_len++; // For C or Z
 | 
			
		||||
    printf("\r");
 | 
			
		||||
    length = 4 + 17 + strlen(password) + 1 + 1 /* For Ctrl+Z/C */;
 | 
			
		||||
    while (length--)
 | 
			
		||||
    while (print_len--)
 | 
			
		||||
        printf(" ");
 | 
			
		||||
    printf("\n");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user