From b70e70e3ddde7a0d8fe236b30a07d7727ecfb10a Mon Sep 17 00:00:00 2001 From: liv Date: Tue, 11 Apr 2017 10:51:56 +0100 Subject: [PATCH 1/3] Add option to mask single blank spaces --- src/nms.c | 5 ++++- src/nmseffect.c | 24 +++++++++++++++++++++--- src/nmseffect.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/nms.c b/src/nms.c index df9dd74..c63cd44 100644 --- a/src/nms.c +++ b/src/nms.c @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) { char *input = NULL; // Processing command arguments - while ((o = getopt(argc, argv, "f:acv")) != -1) { + while ((o = getopt(argc, argv, "f:ascv")) != -1) { switch (o) { case 'f': nmseffect_set_foregroundcolor(optarg); @@ -27,6 +27,9 @@ int main(int argc, char *argv[]) { case 'a': nmseffect_set_autodecrypt(1); break; + case 's': + nmseffect_set_maskblank(1); + break; case 'c': nmseffect_set_clearscr(1); break; diff --git a/src/nmseffect.c b/src/nmseffect.c index 1b802e5..195d5f1 100644 --- a/src/nmseffect.c +++ b/src/nmseffect.c @@ -34,6 +34,7 @@ // Behavior settings static char *returnOpts = NULL; // Return option setting static int autoDecrypt = 0; // Auto-decrypt flag +static int maskBlank = 0; // Mask blank spaces static int colorOn = 1; // Terminal color flag static int inputPositionX = -1; // X coordinate for input position static int inputPositionY = -1; // Y coordinate for input position @@ -136,10 +137,15 @@ char nmseffect_exec(char *string) { } // Set flag if we have a whitespace character - if (strlen(list_pointer->source) == 1 && isspace(list_pointer->source[0])) - list_pointer->is_space = 1; - else + if (strlen(list_pointer->source) == 1 && isspace(list_pointer->source[0])) { + // If flag is enabled, mask blank spaces as well + if (maskBlank && (list_pointer->source[0] == ' ')) + list_pointer->is_space = 0; + else + list_pointer->is_space = 1; + } else { list_pointer->is_space = 0; + } // Set initial mask chharacter list_pointer->mask = nmscharset_get_random(); @@ -349,6 +355,18 @@ void nmseffect_set_autodecrypt(int setting) { autoDecrypt = 0; } +/* + * Set the maskBlank flag according to the true/false value of the + * 'setting' argument. When set to true, blank spaces characters + * will be masked as well. + */ +void nmseffect_set_maskblank(int setting) { + if (setting) + maskBlank = 1; + else + maskBlank = 0; +} + /* * Pass the 'setting' argument to the nmstermio module where it will set * the clearScr flag according to the true/false value. When set to true, diff --git a/src/nmseffect.h b/src/nmseffect.h index 152e2ba..5c04c3d 100644 --- a/src/nmseffect.h +++ b/src/nmseffect.h @@ -13,6 +13,7 @@ char nmseffect_exec(char *); void nmseffect_set_foregroundcolor(char *); void nmseffect_set_returnopts(char *); void nmseffect_set_autodecrypt(int); +void nmseffect_set_maskblank(int); void nmseffect_set_clearscr(int); void nmseffect_use_color(int); void nmseffect_set_input_position(int, int); From 33fa5bd55786f920fd933518b60f3bf950c571de Mon Sep 17 00:00:00 2001 From: liv Date: Tue, 11 Apr 2017 11:08:33 +0100 Subject: [PATCH 2/3] Add mask blanks to man page --- nms.6 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nms.6 b/nms.6 index 2d41775..10a6676 100644 --- a/nms.6 +++ b/nms.6 @@ -11,6 +11,9 @@ nms [options] .B -a sets the auto-decrypt flag, decryption sequence starts without requiring a key press. .TP +.B -s +sets the mask blanks flag. Blank spaces will be encrypted and decrypted. +.TP .B -c clear the screen prior to printing any output .TP From f8348b8567d3de8d802bd44d448bd3d4a5ede47a Mon Sep 17 00:00:00 2001 From: livz Date: Tue, 11 Apr 2017 11:10:51 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 754a00c..15b2b99 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ enjoy the magic. In the below examples, I use a simple directory listing. ``` ls -l | nms ls -l | nms -a // Set auto-decrypt flag +ls -l | nms -s // Set mask blanks flag ls -l | nms -f green // Set foreground color to green ls -l | nms -c // Clear screen nms -v // Display version