diff options
author | nathansmith117 <nathansmith117@sdf.org> | 2024-05-22 04:51:55 +0000 |
---|---|---|
committer | nathansmith117 <nathansmith117@sdf.org> | 2024-05-22 04:51:55 +0000 |
commit | bdd8d563ff3f0eec41cc45d07f6c00622a531a72 (patch) | |
tree | ceb9cac325b893b20b5d0303e988252136680e03 /swall | |
download | forgorttonProjects-bdd8d563ff3f0eec41cc45d07f6c00622a531a72.tar.gz forgorttonProjects-bdd8d563ff3f0eec41cc45d07f6c00622a531a72.tar.bz2 forgorttonProjects-bdd8d563ff3f0eec41cc45d07f6c00622a531a72.zip |
Diffstat (limited to 'swall')
-rw-r--r-- | swall/Makefile | 24 | ||||
-rw-r--r-- | swall/README.md | 2 | ||||
-rw-r--r-- | swall/scomm.3 | 15 | ||||
-rw-r--r-- | swall/scomm.c | 55 | ||||
-rw-r--r-- | swall/swall.3 | 9 | ||||
-rw-r--r-- | swall/swall.c | 57 |
6 files changed, 162 insertions, 0 deletions
diff --git a/swall/Makefile b/swall/Makefile new file mode 100644 index 0000000..9ee927b --- /dev/null +++ b/swall/Makefile @@ -0,0 +1,24 @@ +all: swall scomm +debug: d_swall d_scomm + +swall: swall.c + gcc -o swall swall.c +d_swall: swall.c + gcc -o swall swall.c -g +scomm: scomm.c + gcc -o scomm scomm.c +d_scomm: scomm.c + gcc -o scomm scomm.c -g +install: + sudo cp swall /usr/local/bin/ + sudo cp swall.3 /usr/share/man/man3/swall.3 + sudo cp scomm /usr/local/bin/ + sudo cp scomm.3 /usr/share/man/man3/scomm.3 +uninstall: + sudo rm /usr/local/bin/swall + sudo rm /usr/share/man/man3/swall.3 + sudo rm /usr/local/bin/scomm + sudo rm /usr/share/man/man3/scomm.3 +reinstall: uninstall install +clean: + rm swall scomm diff --git a/swall/README.md b/swall/README.md new file mode 100644 index 0000000..2f9c019 --- /dev/null +++ b/swall/README.md @@ -0,0 +1,2 @@ +# swall +It seems to be my take on the wall command. It's ugly so good luck if you decide to look at it. diff --git a/swall/scomm.3 b/swall/scomm.3 new file mode 100644 index 0000000..26fbc43 --- /dev/null +++ b/swall/scomm.3 @@ -0,0 +1,15 @@ +./" scomm +.TH scomm 3 "2021" "scomm" + +.SH NAME + scomm +.SH DESCRIPTION + scomm is the swall command line. Also see swall. +.SH COMMANDS + - exit to exit. + + - clsme to clear your page. + + - echomod turns echomod on and of. echomod prints a message in stead of a command. + + - clear and clsme will work the same in echomod and normall mode. diff --git a/swall/scomm.c b/swall/scomm.c new file mode 100644 index 0000000..a5a2eb7 --- /dev/null +++ b/swall/scomm.c @@ -0,0 +1,55 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main() { + int echomod = 0; + char msg[50], com[100]; + + while (!feof(stdin)) { + + if (echomod) + printf("echo "); + else + printf("--> "); + + memset(msg, 0, sizeof(msg)); + memset(com, 0, sizeof(com)); + fgets(msg, sizeof(msg), stdin); + + if (!strncmp(msg,"\n", sizeof(msg))) + continue; + else if (!strncmp(msg, "exit\n", sizeof(msg))) { + + if (echomod) { + echomod = 0; + continue; + } + + break; + } else if (!strncmp(msg, "echomod\n", sizeof(msg))) { + + if (echomod) + echomod = 0; + else + echomod = 1; + + continue; + } else if (!strncmp(msg, "clsme\n", sizeof(msg))) { + system("clear"); + continue; + } else if (!strncmp(msg, "clear\n", sizeof(msg))) { + system("swall clear"); + continue; + } + + if (echomod) + snprintf(com, sizeof(com), "swall echo %s", msg); + else + snprintf(com, sizeof(com), "swall %s", msg); + + system(com); + } + + return 0; +} diff --git a/swall/swall.3 b/swall/swall.3 new file mode 100644 index 0000000..0bd0d66 --- /dev/null +++ b/swall/swall.3 @@ -0,0 +1,9 @@ +./" swall +.TH swall 3 "2021" "swall" + +.SH NAME + swall +.SH SYNOPSIS + swall [command] +.SH DESCRIPTION + swall = super wall. It runs the same command in all shells. Also see scomm and wall. diff --git a/swall/swall.c b/swall/swall.c new file mode 100644 index 0000000..97865f1 --- /dev/null +++ b/swall/swall.c @@ -0,0 +1,57 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> + +int file_exis(const char * file_name) { + FILE * fp; + + if ((fp = fopen(file_name, "r"))) { + fclose(fp); + return 1; + } + + return 0; +} + +int main(int argc, char ** argv) { + int i; + + if (argc < 2) { + fputs("No arguments found.\n", stderr); + return -1; + } + + size_t the_size = strlen(argv[1]); + char msg[the_size]; + memset(msg, 0, the_size); + + strncat(msg, argv[1], sizeof(msg)); + + for (i = 2; i < argc; i++) { + strncat(msg, " ", the_size); + strncat(msg, argv[i], the_size); + } + + char com[100]; + char file_msg[15]; + + for (i = 0; i < 100; i++) { + snprintf(file_msg, sizeof(file_msg), "/dev/pts/%d", i); + + if (file_exis(file_msg)) { + snprintf(com, sizeof(com), "%s > %s", msg, file_msg); + system(com); + } + + snprintf(file_msg, sizeof(file_msg), "/dev/tty%d", i); + + if (file_exis(file_msg)) { + snprintf(com, sizeof(com), "%s > %s", msg, file_msg); + system(com); + } + } + + + return 0; +} |