diff options
author | June McEnroe <june@causal.agency> | 2018-08-23 15:52:58 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-08-23 15:52:58 -0400 |
commit | 7f2e7db45c4b2f7db9c84338fda83875a7855317 (patch) | |
tree | 1b4b1034913405bed5a36e35cb8148d9e7443cd3 | |
parent | Add g for flip (diff) | |
download | torus-7f2e7db45c4b2f7db9c84338fda83875a7855317.tar.gz torus-7f2e7db45c4b2f7db9c84338fda83875a7855317.zip |
Remove help
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | help.c | 187 |
3 files changed, 3 insertions, 191 deletions
diff --git a/.gitignore b/.gitignore index 7f76e0f..230472d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *.o chroot.tar client -help merge meta root diff --git a/Makefile b/Makefile index f2b2ca0..2b0ca87 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CHROOT_GROUP = $(CHROOT_USER) CFLAGS += -Wall -Wextra -Wpedantic LDLIBS = -lm -lcursesw -BINS = server client help meta merge +BINS = server client meta merge OBJS = $(BINS:%=%.o) all: tags $(BINS) @@ -13,7 +13,7 @@ $(OBJS): torus.h tags: *.h *.c ctags -w *.h *.c -chroot.tar: server client help +chroot.tar: server client mkdir -p root install -d -o root -g wheel \ root/bin \ @@ -35,7 +35,7 @@ chroot.tar: server client help cp -a -f /usr/share/locale root/usr/share cp -p -f /usr/share/misc/termcap.db root/usr/share/misc cp -p -f /bin/sh root/bin - install -o root -g wheel -m 555 server client help root/bin + install -o root -g wheel -m 555 server client root/bin tar -c -f chroot.tar -C root bin home lib libexec usr clean: diff --git a/help.c b/help.c deleted file mode 100644 index dd13c4f..0000000 --- a/help.c +++ /dev/null @@ -1,187 +0,0 @@ -/* Copyright (C) 2017 June McEnroe <june@causal.agency> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <err.h> -#include <stdint.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sysexits.h> -#include <unistd.h> - -#include "torus.h" - -static int client; - -static void clientMessage(struct ClientMessage msg) { - ssize_t size = send(client, &msg, sizeof(msg), 0); - if (size < 0) err(EX_IOERR, "send"); -} - -static void clientMove(int8_t dx, int8_t dy) { - struct ClientMessage msg = { - .type = CLIENT_MOVE, - .move = { .dx = dx, .dy = dy }, - }; - clientMessage(msg); -} - -static void clientPut(uint8_t color, char cell) { - struct ClientMessage msg = { - .type = CLIENT_PUT, - .put = { .color = color, .cell = cell }, - }; - clientMessage(msg); -} - -static const useconds_t DELAY = 50000; - -enum { - K = COLOR_BLACK, - R = COLOR_RED, - G = COLOR_GREEN, - Y = COLOR_YELLOW, - B = COLOR_BLUE, - M = COLOR_MAGENTA, - C = COLOR_CYAN, - W = COLOR_WHITE, - I = COLOR_BRIGHT | COLOR_WHITE, -}; - -static void h(void) { clientMove(-1, 0); usleep(DELAY); } -static void j(void) { clientMove( 0, 1); usleep(DELAY); } -static void k(void) { clientMove( 0, -1); usleep(DELAY); } -static void l(void) { clientMove( 1, 0); usleep(DELAY); } -static void y(void) { clientMove(-1, -1); usleep(DELAY); } -static void u(void) { clientMove( 1, -1); usleep(DELAY); } -static void b(void) { clientMove(-1, 1); usleep(DELAY); } -static void n(void) { clientMove( 1, 1); usleep(DELAY); } - -static void p(uint8_t color, char cell) { - clientPut(color, cell); - usleep(DELAY); -} - -static uint8_t len; - -static void s(uint8_t color, const char *str) { - for (; *str; ++len, ++str) { - clientPut(color, *str); - clientMove(1, 0); - usleep(DELAY); - } -} - -static void r(void) { - clientMove(-len, 1); - usleep(DELAY); - len = 0; -} - -int main() { - client = socket(PF_LOCAL, SOCK_STREAM, 0); - if (client < 0) err(EX_OSERR, "socket"); - - struct sockaddr_un addr = { - .sun_family = AF_LOCAL, - .sun_path = "torus.sock", - }; - int error = connect(client, (struct sockaddr *)&addr, sizeof(addr)); - if (error) err(EX_NOINPUT, "torus.sock"); - - pid_t pid = fork(); - if (pid < 0) err(EX_OSERR, "fork"); - - if (!pid) { - for (;;) { - char buf[4096]; - ssize_t size = recv(client, buf, sizeof(buf), 0); - if (size < 0) err(EX_IOERR, "recv"); - if (!size) return EX_OK; - } - } - - clientMove(-CELL_INIT_X, -CELL_INIT_Y); - clientMove(28, 0); - - for (;;) { - for (int i = 0; i < 10; ++i) { - clientMove(0, 1); - usleep(DELAY / 5); - } - for (int i = 0; i < 11; ++i) { - for (int j = 0; j < 28; ++j) { - clientPut(W, ' '); - if (i % 2) clientMove(1, 0); - else clientMove(-1, 0); - usleep(DELAY / 5); - } - clientPut(W, ' '); - if (i != 10) clientMove(0, -1); - usleep(DELAY / 5); - } - - j(); l(); l(); - s(W, "Welcome to "); s(I, "ascii.town"); s(W, "!"); r(); - r(); r(); - - n(); n(); s(W, "o-"); s(I, "l"); - h(); b(); p(W, '\\'); n(); p(I, 'n'); - y(); h(); p(W, '|'); j(); p(I, 'j'); - y(); p(W, '/'); b(); p(I, 'b'); - k(); u(); p(W, '-'); h(); p(I, 'h'); - u(); p(W, '\\'); y(); p(I, 'y'); - n(); l(); p(W, '|'); k(); p(I, 'k'); - n(); p(W, '/'); u(); p(I, 'u'); - - u(); s(W, " "); len = 0; - - s(I, "q "); s(W, "quit"); r(); - s(I, "i "); s(W, "insert"); r(); - s(I, "r "); s(W, "replace"); r(); - s(I, "R "); s(W, "draw"); r(); - s(I, "~ "); s(W, "color"); r(); - s(I, "` "); s(W, "pipette"); r(); - s(I, "* "); s(W, "bright"); - - s(W, " "); len = 0; - - clientPut(W, '7'); k(); - clientPut(C, '6'); k(); - clientPut(M, '5'); k(); - clientPut(B, '4'); k(); - clientPut(Y, '3'); k(); - clientPut(G, '2'); k(); - clientPut(R, '1'); k(); - clientPut(K, '0'); - - l(); l(); - - clientPut(K << 4, ')'); j(); - clientPut(R << 4, '!'); j(); - clientPut(G << 4, '@'); j(); - clientPut(Y << 4, '#'); j(); - clientPut(B << 4, '$'); j(); - clientPut(M << 4, '%'); j(); - clientPut(C << 4, '^'); j(); - clientPut(W << 4, '&'); j(); - - h(); k(); k(); k(); k(); k(); k(); k(); k(); k(); h(); - - sleep(30); - - u(); l(); l(); l(); - } -} |