diff options
| author | Mattias Andrée <maandree@operamail.com> | 2015-12-05 16:42:17 +0100 | 
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2015-12-05 16:42:17 +0100 | 
| commit | e5c01e102c790a918ecfda66cfce7cb5e5f8af0a (patch) | |
| tree | d2ab239d8a3d664c793b3d35fd34e9f0030cede2 /src | |
| parent | add description of strength value (diff) | |
| download | libpassphrase-e5c01e102c790a918ecfda66cfce7cb5e5f8af0a.tar.gz libpassphrase-e5c01e102c790a918ecfda66cfce7cb5e5f8af0a.tar.bz2 libpassphrase-e5c01e102c790a918ecfda66cfce7cb5e5f8af0a.tar.xz | |
customisable meter
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
| -rw-r--r-- | src/passphrase.c | 11 | ||||
| -rw-r--r-- | src/passphrase_helper.h | 19 | 
2 files changed, 21 insertions, 9 deletions
| diff --git a/src/passphrase.c b/src/passphrase.c index 33c7276..01e96cb 100644 --- a/src/passphrase.c +++ b/src/passphrase.c @@ -307,13 +307,10 @@ static void passcheck_update(struct passcheck_state* state, const char* passphra      }    strength_ptr = 0; -  /* TODO locale */ -  if      (value ==   0)  desc = "1;31m"   "Well-known common password"; -  else if (value <= 150)  desc = "31m"     "Extremely week"; -  else if (value <= 200)  desc = "33m"     "Week"; -  else if (value <= 250)  desc = "32m"     "Good"; -  else if (value <= 350)  desc = "1;32m"   "Strong"; -  else                    desc = "1;7;32m" "Perfect"; +  if (0); +#define X(COND, COLOUR, DESC)  else if (COND)  desc = COLOUR"m"DESC; +  LIST_PASSPHRASE_STRENGTH_LIMITS(value) +#undef X    if (state->flags & PASSPHRASE_READ_SCREEN_FREE)      fprintf(stderr, "\033[s\033[E\033[0K%s \033[%s\033[m (%lli)\033[u", state->label, desc, value); diff --git a/src/passphrase_helper.h b/src/passphrase_helper.h index e41ca0c..ccc927d 100644 --- a/src/passphrase_helper.h +++ b/src/passphrase_helper.h @@ -20,6 +20,7 @@  #define PASSPHRASE_HELPER_H +  /* Fix conflicting configurations */  #if defined(PASSPHRASE_TEXT) && defined(PASSPHRASE_STAR)  # warning You cannot have both PASSPHRASE_TEXT and PASSPHRASE_STAR @@ -50,8 +51,22 @@  #endif +/* Strength limits and descriptions */ +#ifdef PASSPHRASE_STRENGTH_LIMITS_HEADER +# include PASSPHRASE_STRENGTH_LIMITS_HEADER +#else +# define LIST_PASSPHRASE_STRENGTH_LIMITS(V)		\ +  X(V == 0,   "1;31",   "Well-known common password")	\ +  X(V <= 150, "31",     "Extremely week")		\ +  X(V <= 200, "33",     "Week")				\ +  X(V <= 250, "32",     "Good")				\ +  X(V <= 350, "1;32",   "Strong")			\ +  X(1,        "1;7;32", "Perfect") +#endif + + -/* Control keys. */ +/* Control keys */  /**   * Home-key. @@ -102,7 +117,7 @@ -/* Use by macros below to ensure that the result is not used. */ +/* Use by macros below to ensure that the result is not used */  #define VOID(...)  do { __VA_ARGS__; } while (0) | 
