aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/securecoreutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/securecoreutils.c')
-rw-r--r--src/securecoreutils.c70
1 files changed, 70 insertions, 0 deletions
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 @@
82int main(int argc, char * argv[]); 85int main(int argc, char * argv[]);
83const char * scu_basename(const char * path); 86const char * scu_basename(const char * path);
84const scu_widget * scu_widget_lookup(const char * wname, int exact); 87const scu_widget * scu_widget_lookup(const char * wname, int exact);
88int 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
545int 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
525const char * scu_strerror(int err) 595const char * scu_strerror(int err)
526{ 596{
527 if (err < 0) 597 if (err < 0)