-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.h
82 lines (68 loc) · 2 KB
/
status.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-2001,2006,2011,2013,2017 by Solar Designer
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*/
/*
* Status information management routines.
*/
#ifndef _JOHN_STATUS_H
#define _JOHN_STATUS_H
#include <stdint.h>
#include <time.h>
/*
* Current status.
*/
struct status_main {
clock_t start_time;
unsigned int guess_count;
uint64_t combs, crypts, cands;
unsigned int combs_ehi;
int compat;
int pass;
int progress;
};
extern struct status_main status;
extern int (*status_get_progress)(void);
/*
* Elapsed time of previous sessions and excess ticks (if any), in seconds.
*/
extern unsigned int status_restored_time;
/*
* If start is non-zero, sets start_time to current time and the rest of
* fields to zero. Always initializes the get_progress() handler (can be
* NULL).
*/
extern void status_init(int (*get_progress)(void), int start);
/*
* Checks the number of ticks elapsed since start_time and moves some excess
* ticks onto status_restored_time (by increasing both it and start_time)
* such that the difference between the current system time in ticks (which
* may overflow) and start_time always correctly represents the number of
* ticks elapsed since status_restored_time.
*/
extern void status_ticks_overflow_safety(void);
/*
* Updates the combinations and crypts counters by adding the supplied numbers
* to them.
* Calls status_ticks_overflow_safety() once in a while.
*/
extern void status_update_crypts(uint64_t combs, unsigned int crypts);
/*
* Updates the candidates counter by adding the supplied number to it.
* Calls status_ticks_overflow_safety() once in a while.
*/
extern void status_update_cands(unsigned int cands);
/*
* Returns the elapsed time in seconds.
*/
extern unsigned int status_get_time(void);
/*
* Prints current status to stdout.
*/
extern void status_print(void);
#endif