diff options
author | June McEnroe <june@causal.agency> | 2019-02-05 02:07:53 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-02-05 02:07:53 -0500 |
commit | 0752287a116694752c414e247c1c327d17298f32 (patch) | |
tree | 3703a25f04063b497d9e12158fb47e3a53ae34e7 | |
parent | Set nvim Directory back to blue (diff) | |
download | src-0752287a116694752c414e247c1c327d17298f32.tar.gz src-0752287a116694752c414e247c1c327d17298f32.zip |
Add aes
Okay this should really be aes(6) but I don't feel like adding back MAN6 in the Makefile.
Diffstat (limited to '')
-rw-r--r-- | bin/.gitignore | 1 | ||||
-rw-r--r-- | bin/Makefile | 1 | ||||
-rw-r--r-- | bin/README | 1 | ||||
-rw-r--r-- | bin/aes.c | 57 | ||||
-rw-r--r-- | bin/bin.7 | 3 | ||||
-rw-r--r-- | bin/man1/aes.1 | 18 |
6 files changed, 81 insertions, 0 deletions
diff --git a/bin/.gitignore b/bin/.gitignore index 311e3ccb..d68c33f8 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,4 +1,5 @@ *.o +aes atch beef bri diff --git a/bin/Makefile b/bin/Makefile index a0487a17..619b3f50 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -8,6 +8,7 @@ LDLIBS_cocoa = $(LDLIBS) -framework Cocoa LDLIBS_fb = $(LDLIBS) LDLIBS_x11 = $(LDLIBS) -lX11 +BINS += aes BINS += atch BINS += dtch BINS += glitch diff --git a/bin/README b/bin/README index e7e8f618..478373ae 100644 --- a/bin/README +++ b/bin/README @@ -7,6 +7,7 @@ DESCRIPTION Various tools primarily targeting Darwin, FreeBSD and NetBSD. Some tools target Linux. + aes(1) fullwidth output beef(1) Befunge-93 interpreter bri(1) backlight brightness control brot(1) Mandelbrot renderer diff --git a/bin/aes.c b/bin/aes.c new file mode 100644 index 00000000..cb765934 --- /dev/null +++ b/bin/aes.c @@ -0,0 +1,57 @@ +/* Copyright (C) 2019 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 <locale.h> +#include <stdio.h> +#include <stdlib.h> +#include <wchar.h> + +typedef unsigned char byte; + +static const wchar_t Table[128] = { + L"\x00\x01\x02\x03\x04\x05\x06\x07" + L"\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" + L"\x10\x11\x12\x13\x14\x15\x16\x17" + L"\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F" + L" !"#$%&'()*+,-./" + L"0123456789:;<=>?" + L"@ABCDEFGHIJKLMNO" + L"PQRSTUVWXYZ[\]^_" + L"`abcdefghijklmno" + L"pqrstuvwxyz{|}~\xFF" +}; + +static void enwiden(const char *ch) { + for (; *ch; ++ch) { + if ((byte)*ch < 128) printf("%lc", Table[(byte)*ch]); + else printf("%c", *ch); + } +} + +int main(int argc, char *argv[]) { + setlocale(LC_CTYPE, ""); + for (int i = 1; i < argc; ++i) { + enwiden(argv[i]); + if (i < argc - 1) printf("%lc", Table[' ']); + else printf("\n"); + } + if (argc > 1) return EXIT_SUCCESS; + char *line = NULL; + size_t cap = 0; + while (0 < getline(&line, &cap, stdin)) { + enwiden(line); + } +} diff --git a/bin/bin.7 b/bin/bin.7 index f8f7a7ee..e350ff49 100644 --- a/bin/bin.7 +++ b/bin/bin.7 @@ -16,6 +16,9 @@ Some tools target Linux. . .Pp .Bl -tag -width "fbclock(1)" -compact +.It Xr aes 1 +fullwidth output +. .It Xr beef 1 Befunge-93 interpreter . diff --git a/bin/man1/aes.1 b/bin/man1/aes.1 new file mode 100644 index 00000000..3e8df20b --- /dev/null +++ b/bin/man1/aes.1 @@ -0,0 +1,18 @@ +.Dd February 5, 2019 +.Dt AES 1 +.Os +. +.Sh NAME +.Nm aes +.Nd fullwidth output +. +.Sh SYNOPSIS +.Nm +.Op Ar text ... +. +.Sh DESCRIPTION +.Nm +converts ASCII characters +to their fullwidth counterparts. +If no arguments are given, +standard input is converted. |