From 64bc9540a9c48f9531b54538c433c2cc8f637d21 Mon Sep 17 00:00:00 2001 From: Samuel Matthiesen Date: Fri, 4 Oct 2024 09:38:59 +0200 Subject: Use `static const`s instead of `#define`s for constants. --- lpass.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lpass.c b/lpass.c index fbdc673..40e0bd7 100644 --- a/lpass.c +++ b/lpass.c @@ -27,15 +27,15 @@ #include #include -#define MAX_BUF 1024 -#define ENTROPY_ITERATIONS 100000 -#define ENTROPY_KEY_LENGTH 32 -#define DEFAULT_LENGTH 16 +static const int MAX_BUF = 1024; +static const int ENTROPY_ITERATIONS = 100000; +static const int ENTROPY_KEY_LENGTH = 32; +static const int DEFAULT_LENGTH = 16; -#define CHAR_SUBSET_LOWER "abcdefghijklmnopqrstuvwxyz" -#define CHAR_SUBSET_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -#define CHAR_SUBSET_DIGITS "0123456789" -#define CHAR_SUBSET_SYMBOLS "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" +static const char CHAR_SUBSET_LOWER[] = "abcdefghijklmnopqrstuvwxyz"; +static const char CHAR_SUBSET_UPPER[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +static const char CHAR_SUBSET_DIGITS[] = "0123456789"; +static const char CHAR_SUBSET_SYMBOLS[] = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; enum CharSet { CHARSET_LOWER = 1 << 0, @@ -256,7 +256,8 @@ usage() fputs(" --no-lower no lowercase letters in password\n", stderr); fputs(" --no-upper no uppercase letters in password\n", stderr); fputs(" --no-digits no digits in password\n", stderr); - fputs(" --no-symbols no special symbols (" CHAR_SUBSET_SYMBOLS ")\n", stderr); + fprintf(stderr, + " --no-symbols no special symbols: %s\n", CHAR_SUBSET_SYMBOLS); fputs(" -h, --help output this message and exit\n", stderr); fputs("\nThe environment variable LESSPASS_MASTER_PASSWORD must be set with the master\n", stderr); fputs("password for producing the desired password.\n", stderr); -- cgit v1.2.3