2
0

Make identicon color an optional feature and specify the dependency.

This commit is contained in:
Maarten Billemont 2014-11-21 08:06:29 -05:00
parent 9ab1b2d47a
commit c0ec65bbae
2 changed files with 14 additions and 2 deletions

View File

@ -9,6 +9,8 @@
# try ./build -lrt instead. # try ./build -lrt instead.
# - If you see 'x86.S:202: Error: junk at end of line, first unrecognized character is `,'', # - If you see 'x86.S:202: Error: junk at end of line, first unrecognized character is `,'',
# try commenting the line in lib/bcrypt/x86.S. # try commenting the line in lib/bcrypt/x86.S.
# - Take a look at the "Optional features" section. Some features have dependencies,
# either make sure you have them or disable those features.
# #
# BUGS # BUGS
# masterpassword@lyndir.com # masterpassword@lyndir.com
@ -35,6 +37,9 @@ else
) )
fi fi
# Optional features.
mpw_color=1 # Colorized Identicon, requires libncurses-dev
### DEPENDENCIES ### DEPENDENCIES
@ -192,7 +197,7 @@ mpw() {
# library paths # library paths
-L"." -L"lib/scrypt" -L"." -L"lib/scrypt"
# link libraries # link libraries
-l"crypto" -l"curses" -l"crypto"
# scrypt # scrypt
"lib/scrypt/scrypt-crypto_aesctr.o" "lib/scrypt/scrypt-crypto_aesctr.o"
"lib/scrypt/scrypt-sha256.o" "lib/scrypt/scrypt-sha256.o"
@ -201,6 +206,8 @@ mpw() {
"lib/scrypt/scrypt-scryptenc_cpuperf.o" "lib/scrypt/scrypt-scryptenc_cpuperf.o"
"lib/scrypt/scrypt-scryptenc.o" "lib/scrypt/scrypt-scryptenc.o"
) )
# optional features
(( mpw_color )) && CFLAGS+=( -DCOLOR ) LDFLAGS+=( -l"curses" )
cc "${CFLAGS[@]}" -c types.c -o types.o "$@" cc "${CFLAGS[@]}" -c types.c -o types.o "$@"
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "types.o" mpw.c -o mpw "$@" cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "types.o" mpw.c -o mpw "$@"

View File

@ -217,7 +217,7 @@ const char *Identicon(const char *userName, const char *masterPassword) {
uint8_t identiconSeed[32]; uint8_t identiconSeed[32];
HMAC_SHA256_Buf(masterPassword, strlen(masterPassword), userName, strlen(userName), identiconSeed); HMAC_SHA256_Buf(masterPassword, strlen(masterPassword), userName, strlen(userName), identiconSeed);
char *identicon = (char *)calloc(20, sizeof(char)); #ifdef COLOR
setupterm(NULL, 2, NULL); setupterm(NULL, 2, NULL);
initputvar(); initputvar();
tputs(tparm(tgetstr("AF", NULL), identiconSeed[4] % 7 + 1), 1, putvar); tputs(tparm(tgetstr("AF", NULL), identiconSeed[4] % 7 + 1), 1, putvar);
@ -226,6 +226,11 @@ const char *Identicon(const char *userName, const char *masterPassword) {
tputs(tgetstr("me", NULL), 1, putvar); tputs(tgetstr("me", NULL), 1, putvar);
char reset[strlen(putvarc)]; char reset[strlen(putvarc)];
strcpy(reset, putvarc); strcpy(reset, putvarc);
#else
const char *red = "", *reset = "";
#endif
char *identicon = (char *)calloc(20, sizeof(char));
sprintf(identicon, "%s%s%s%s%s%s", sprintf(identicon, "%s%s%s%s%s%s",
red, red,
left[identiconSeed[0] % (sizeof(left) / sizeof(left[0]))], left[identiconSeed[0] % (sizeof(left) / sizeof(left[0]))],