diff options
| author | David M. Syzdek <syzdek@bindlebinaries.com> | 2017-07-09 00:27:46 -0800 |
|---|---|---|
| committer | David M. Syzdek <syzdek@bindlebinaries.com> | 2017-07-09 00:40:06 -0800 |
| commit | e5e22f34fb35442aa9cd78a41115afa513fb8b47 (patch) | |
| tree | 27473f249f2ab3d5f7e7bb295e4b5115641b8afd | |
| parent | fcd70be6074b2a56f6b2c92e02d968e530c9b80a (diff) | |
| download | securecoreutils-e5e22f34fb35442aa9cd78a41115afa513fb8b47.tar.gz securecoreutils-e5e22f34fb35442aa9cd78a41115afa513fb8b47.tar.bz2 securecoreutils-e5e22f34fb35442aa9cd78a41115afa513fb8b47.tar.xz securecoreutils-e5e22f34fb35442aa9cd78a41115afa513fb8b47.zip | |
Adding easter egg widget
When calling the widget "syzdek", the package name will scroll around the
screen.
| -rw-r--r-- | ChangeLog | 1 | ||||
| -rw-r--r-- | acinclude.m4 | 18 | ||||
| -rw-r--r-- | configure.ac | 1 | ||||
| -rw-r--r-- | src/securecoreutils.c | 70 |
4 files changed, 90 insertions, 0 deletions
| @@ -6,6 +6,7 @@ Copyright (C) 2015, 2017 David M. Syzdek <david@syzdek.net>. | |||
| 6 | - core: adding ability to disable creating widget symlinks (syzdek) | 6 | - core: adding ability to disable creating widget symlinks (syzdek) |
| 7 | - core: updating copyright notices (syzdek) | 7 | - core: updating copyright notices (syzdek) |
| 8 | - core: adding ability to change widget alias prefix at compile time (syzdek) | 8 | - core: adding ability to change widget alias prefix at compile time (syzdek) |
| 9 | - syzdek: adding easter egg widget (syzdek) | ||
| 9 | - tail: allowing timeout to be modified via env variable TAILTIMEOUT (syzdek) | 10 | - tail: allowing timeout to be modified via env variable TAILTIMEOUT (syzdek) |
| 10 | - zcat: fixing segfault with LXMA (.xz) and large files (syzdek) | 11 | - zcat: fixing segfault with LXMA (.xz) and large files (syzdek) |
| 11 | 12 | ||
diff --git a/acinclude.m4 b/acinclude.m4 index 8c0b90c..f24e2f9 100644 --- a/acinclude.m4 +++ b/acinclude.m4 | |||
| @@ -58,6 +58,24 @@ AC_DEFUN([AC_SCU_PREFIX],[dnl | |||
| 58 | ])dnl | 58 | ])dnl |
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | # AC_SCU_EGG | ||
| 62 | # ______________________________________________________________________________ | ||
| 63 | AC_DEFUN([AC_SCU_EGG],[dnl | ||
| 64 | |||
| 65 | enableval="" | ||
| 66 | AC_ARG_ENABLE( | ||
| 67 | easter-egg, | ||
| 68 | [AS_HELP_STRING([--disable-easter-egg], [disable easter egg widget])], | ||
| 69 | [ EEASTER_EGGS=$enableval ], | ||
| 70 | [ EEASTER_EGGS=$enableval ] | ||
| 71 | ) | ||
| 72 | |||
| 73 | if test "x${EEASTER_EGGS}" != "xno";then | ||
| 74 | AC_DEFINE_UNQUOTED(SCU_EASTER_EGGS, 1, [enable easter egg widget]) | ||
| 75 | fi | ||
| 76 | ])dnl | ||
| 77 | |||
| 78 | |||
| 61 | # AC_SCU_SYMLINKS | 79 | # AC_SCU_SYMLINKS |
| 62 | # ______________________________________________________________________________ | 80 | # ______________________________________________________________________________ |
| 63 | AC_DEFUN([AC_SCU_SYMLINKS],[dnl | 81 | AC_DEFUN([AC_SCU_SYMLINKS],[dnl |
diff --git a/configure.ac b/configure.ac index f96ea1d..8aaaee7 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -163,6 +163,7 @@ AC_BINDLE_GIT_PACKAGE_VERSION([contrib/bindletools/build-aux/git-package-version | |||
| 163 | 163 | ||
| 164 | # custom configure options | 164 | # custom configure options |
| 165 | AC_BINDLE_ENABLE_WARNINGS | 165 | AC_BINDLE_ENABLE_WARNINGS |
| 166 | AC_SCU_EGG | ||
| 166 | AC_SCU_PREFIX | 167 | AC_SCU_PREFIX |
| 167 | AC_SCU_SYMLINKS | 168 | AC_SCU_SYMLINKS |
| 168 | AC_SCU_WIDGET_TAIL | 169 | AC_SCU_WIDGET_TAIL |
diff --git a/src/securecoreutils.c b/src/securecoreutils.c index 03a3d81..880d410 100644 --- a/src/securecoreutils.c +++ b/src/securecoreutils.c | |||
| @@ -44,6 +44,9 @@ | |||
| 44 | #include "securecoreutils.h" | 44 | #include "securecoreutils.h" |
| 45 | 45 | ||
| 46 | #include <stdio.h> | 46 | #include <stdio.h> |
| 47 | #include <termios.h> | ||
| 48 | #include <sys/ioctl.h> | ||
| 49 | #include <math.h> | ||
| 47 | #include <assert.h> | 50 | #include <assert.h> |
| 48 | #include <string.h> | 51 | #include <string.h> |
| 49 | #include <strings.h> | 52 | #include <strings.h> |
| @@ -82,6 +85,7 @@ | |||
| 82 | int main(int argc, char * argv[]); | 85 | int main(int argc, char * argv[]); |
| 83 | const char * scu_basename(const char * path); | 86 | const char * scu_basename(const char * path); |
| 84 | const scu_widget * scu_widget_lookup(const char * wname, int exact); | 87 | const scu_widget * scu_widget_lookup(const char * wname, int exact); |
| 88 | int scu_widget_syzdek(scu_config * cnf); | ||
| 85 | 89 | ||
| 86 | 90 | ||
| 87 | ///////////////// | 91 | ///////////////// |
| @@ -119,6 +123,14 @@ const scu_widget scu_widget_map[] = | |||
| 119 | (const char * const[]) { _PREFIX"rmdir", NULL },// widget alias | 123 | (const char * const[]) { _PREFIX"rmdir", NULL },// widget alias |
| 120 | scu_widget_rmdir, // widget function | 124 | scu_widget_rmdir, // widget function |
| 121 | }, | 125 | }, |
| 126 | #ifdef SCU_EASTER_EGGS | ||
| 127 | { | ||
| 128 | "syzdek", // widget name | ||
| 129 | NULL, // widget description | ||
| 130 | (const char * const[]) { "david", NULL }, // widget alias | ||
| 131 | scu_widget_syzdek, // widget function | ||
| 132 | }, | ||
| 133 | #endif | ||
| 122 | { | 134 | { |
| 123 | "tail", // widget name | 135 | "tail", // widget name |
| 124 | "Writes contents of file to standard out.", // widget description | 136 | "Writes contents of file to standard out.", // widget description |
| @@ -345,6 +357,8 @@ void scu_usage(scu_config * cnf) | |||
| 345 | { | 357 | { |
| 346 | if (scu_widget_map[x].func == NULL) | 358 | if (scu_widget_map[x].func == NULL) |
| 347 | continue; | 359 | continue; |
| 360 | if (scu_widget_map[x].desc == NULL) | ||
| 361 | continue; | ||
| 348 | printf(" %-24s %s\n", scu_widget_map[x].name, scu_widget_map[x].desc); | 362 | printf(" %-24s %s\n", scu_widget_map[x].name, scu_widget_map[x].desc); |
| 349 | }; | 363 | }; |
| 350 | printf("\n"); | 364 | printf("\n"); |
| @@ -356,6 +370,8 @@ void scu_usage(scu_config * cnf) | |||
| 356 | continue; | 370 | continue; |
| 357 | if (scu_widget_map[x].alias == NULL) | 371 | if (scu_widget_map[x].alias == NULL) |
| 358 | continue; | 372 | continue; |
| 373 | if (scu_widget_map[x].desc == NULL) | ||
| 374 | continue; | ||
| 359 | printf(" %-24s %s\n", scu_widget_map[x].name, scu_widget_map[x].alias[0]); | 375 | printf(" %-24s %s\n", scu_widget_map[x].name, scu_widget_map[x].alias[0]); |
| 360 | for (y = 1; scu_widget_map[x].alias[y] != NULL; y++) | 376 | for (y = 1; scu_widget_map[x].alias[y] != NULL; y++) |
| 361 | printf(" %-21s %s\n", " ", scu_widget_map[x].alias[y]); | 377 | printf(" %-21s %s\n", " ", scu_widget_map[x].alias[y]); |
| @@ -465,6 +481,9 @@ const scu_widget * scu_widget_lookup(const char * wname, int exact) | |||
| 465 | prefix_uniq = -1; | 481 | prefix_uniq = -1; |
| 466 | prefix_common = -1; | 482 | prefix_common = -1; |
| 467 | 483 | ||
| 484 | if (!(strcasecmp(PROGRAM_NAME, wname))) | ||
| 485 | return(NULL); | ||
| 486 | |||
| 468 | for(x = 0; scu_widget_map[x].name != NULL; x++) | 487 | for(x = 0; scu_widget_map[x].name != NULL; x++) |
| 469 | { | 488 | { |
| 470 | widget = &scu_widget_map[x]; | 489 | widget = &scu_widget_map[x]; |
| @@ -522,6 +541,57 @@ const scu_widget * scu_widget_lookup(const char * wname, int exact) | |||
| 522 | } | 541 | } |
| 523 | 542 | ||
| 524 | 543 | ||
| 544 | #ifdef SCU_EASTER_EGGS | ||
| 545 | int scu_widget_syzdek(scu_config * cnf) | ||
| 546 | { | ||
| 547 | unsigned z; | ||
| 548 | double x; | ||
| 549 | double w; | ||
| 550 | double h; | ||
| 551 | #ifdef TIOCGSIZE | ||
| 552 | struct ttysize b; | ||
| 553 | #else | ||
| 554 | struct winsize b; | ||
| 555 | #endif | ||
| 556 | const char * package = "Secure Core Utilities"; | ||
| 557 | const char * author = "by David M. Syzdek"; | ||
| 558 | const char * msg = PACKAGE_NAME " v" PACKAGE_VERSION " by David M. Syzdek"; | ||
| 559 | |||
| 560 | assert(cnf != NULL); | ||
| 561 | |||
| 562 | x = 0.0; | ||
| 563 | |||
| 564 | while(1) | ||
| 565 | { | ||
| 566 | #ifdef TIOCGSIZE | ||
| 567 | w = ioctl(0,TIOCGSIZE,&b) ? 80 : b.ts_cols; | ||
| 568 | h = b.ts_lines; | ||
| 569 | #else | ||
| 570 | w = ioctl(0,TIOCGWINSZ,&b) ? 80 : b.ws_col; | ||
| 571 | h = b.ws_row; | ||
| 572 | #endif | ||
| 573 | for (z = 0; z < strlen(msg)+1; z++) | ||
| 574 | { | ||
| 575 | printf("\033[%i;%iH\033[1;%im%c\033[0m", | ||
| 576 | //(int)((sin(((x-z)*(360.0/h))/57.3)*(h/2.0))+((h/2.0)+1.0)), | ||
| 577 | (int)(( sin(((x-z)*(360.0/h))/80) * (h/2.0)) + ((h/2.0)+1.0) ), | ||
| 578 | (int)(( sin(((x-z)*(360.0/w))/80) * (w/2.0)) + ((w/2.0)+1.0) ), | ||
| 579 | 30+(z%8), | ||
| 580 | msg[z]); | ||
| 581 | }; | ||
| 582 | printf("\033[%i;%iH%s", (int)h-1, (int)w - (int)strlen(package), package); | ||
| 583 | printf("\033[%i;%iH%s", (int)h, (int)w - (int)strlen(author), author); | ||
| 584 | fflush(stdout); | ||
| 585 | usleep(100000); | ||
| 586 | printf("\033[2J\033[512;512H"); | ||
| 587 | x += 1; | ||
| 588 | }; | ||
| 589 | |||
| 590 | return(0); | ||
| 591 | } | ||
| 592 | #endif | ||
| 593 | |||
| 594 | |||
| 525 | const char * scu_strerror(int err) | 595 | const char * scu_strerror(int err) |
| 526 | { | 596 | { |
| 527 | if (err < 0) | 597 | if (err < 0) |
