aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlns <matzeton@googlemail.com>2019-11-13 21:11:53 +0100
committerlns <matzeton@googlemail.com>2019-11-13 21:11:53 +0100
commitba18c15d4173e204fde6eaac9f287a2adf6bea91 (patch)
tree04b9e3ae3a982ad889ed4b2c5229c6eab783178f
parentf6a9c1385bb73cd3c1e5b8f401d214328909c196 (diff)
parent76b7541da755812cdcb0e60c13add8a155444d74 (diff)
Merge branch 'master' of ssh://git.lan:/git/tools
-rw-r--r--Makefile22
-rw-r--r--README.md10
-rw-r--r--textify.c123
3 files changed, 17 insertions, 138 deletions
diff --git a/Makefile b/Makefile
index b5c3d6a..c13c337 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,11 @@
CC := gcc
-INSTALL := install
+INSTALL_DIR := install -d
+INSTALL_BIN := install -s
CFLAGS := -O2 -g -Wall -ffunction-sections -fdata-sections -ffast-math -fomit-frame-pointer -fexpensive-optimizations -Wl,--gc-sections
LDFLAGS :=
RM := rm -rf
-TARGETS := aes asciihexer dummyshell suidcmd ascii85 textify progressbar
+TARGETS := aes asciihexer dummyshell suidcmd ascii85 progressbar
ifneq ($(strip $(MAKE_NCURSES)),)
TARGETS += gol
@@ -41,13 +42,6 @@ ascii85: ascii85.o
@echo 'Finished building target: $@'
@echo ' '
-textify: textify.o
- @echo 'Building target: $@'
- @echo 'Invoking: GCC C Linker'
- $(CC) $(LDFLAGS) -o "$@" "$<" -lm
- @echo 'Finished building target: $@'
- @echo ' '
-
gol: gol.o
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
@@ -80,14 +74,14 @@ strip:
strip -s $(TARGETS)
clean:
- -$(RM) aes.o asciihexer.o dummyshell.o gol.o suidcmd.o ascii85.o textify.o xidle.o xdiff.o
- -$(RM) aes.d asciihexer.d dummyshell.d gol.d suidcmd.d scrambler.d textify.d xidle.d xdiff.d
- -$(RM) aes asciihexer dummyshell gol suidcmd scrambler textify xidle xdiff
+ -$(RM) aes.o asciihexer.o dummyshell.o gol.o suidcmd.o ascii85.o progressbar.o xidle.o xdiff.o
+ -$(RM) aes.d asciihexer.d dummyshell.d gol.d suidcmd.d scrambler.d progressbar.d xidle.d xdiff.d
+ -$(RM) aes asciihexer dummyshell gol suidcmd scrambler progressbar xidle xdiff
-@echo ' '
install: $(TARGETS)
- $(INSTALL) -d $(PREFIX)/usr/bin
- $(INSTALL) -s $(TARGETS) $(PREFIX)/usr/bin
+ $(INSTALL_DIR) -d $(PREFIX)/usr/bin
+ $(INSTALL_BIN) -s $(TARGETS) $(PREFIX)/usr/bin
rebuild: clean all
diff --git a/README.md b/README.md
index 953f403..d0e88d3 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,10 @@ aes.c
========
A minimal working CLI based aes implementation.<br />
+ascii85
+========
+A C&P'ed ASCII-85 converter.<br />
+
asciihexer.c
========
Magic ascii-2-hex app.<br />
@@ -15,7 +19,11 @@ A minimalistic restricted system-usage/messaging/command-exec shell.<br />
gol.c
========
-Conway's GameOfLife - written by Steffen Vogel / bugfixed,improved by myself. <br />
+Conway's GameOfLife - written by Steffen Vogel / bugfixed,improved by myself.<br />
+
+progressbar.c
+========
+A simple progressbar cmdline viewer - view the current fd position of a given path.<br />
suidcmd.c
========
diff --git a/textify.c b/textify.c
deleted file mode 100644
index a88de2c..0000000
--- a/textify.c
+++ /dev/null
@@ -1,123 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-
-#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
-#define BYTE_TO_BINARY(byte) \
- (byte & 0x80 ? '1' : '0'), \
- (byte & 0x40 ? '1' : '0'), \
- (byte & 0x20 ? '1' : '0'), \
- (byte & 0x10 ? '1' : '0'), \
- (byte & 0x08 ? '1' : '0'), \
- (byte & 0x04 ? '1' : '0'), \
- (byte & 0x02 ? '1' : '0'), \
- (byte & 0x01 ? '1' : '0')
-
-
-void print_binary_hex(uint8_t *bin, size_t siz)
-{
- size_t i;
-
- for (i = 0; i < siz; ++i) {
- printf("%8.02X ", bin[i]);
- }
- printf("\n");
- for (i = 0; i < siz; ++i) {
- printf("%8.d ", bin[i]);
- }
- printf("\n");
- for (i = 0; i < siz; ++i) {
- printf(BYTE_TO_BINARY_PATTERN " ", BYTE_TO_BINARY(bin[i]));
- }
- printf("\n");
-}
-
-ssize_t textify(uint8_t *bin, size_t siz, char *out, size_t outsiz)
-{
- size_t i, j;
-
- if (!bin || !out)
- return -1;
-
- for (i = 0, j = 0; i < siz && j < outsiz / 3; ++i, j += 3) {
- uint8_t tmp0 = 32, tmp1 = 64, tmp2 = 64;
-
- if (bin[i] < 32)
- tmp1 = bin[i] + 32;
- else if (bin[i] >= 127) {
- if (bin[i] < 190)
- tmp1 = bin[i] - 63;
- else
- tmp2 = bin[i] - 63*2;
- } else {
- tmp0 = bin[i];
- }
-
- out[j+0] = tmp0;
- out[j+1] = tmp1;
- out[j+2] = tmp2;
- }
-
- return j;
-}
-
-ssize_t untextify(uint8_t *text, size_t siz, char *out, size_t outsiz)
-{
- size_t i, j;
-
- if (!text || !out)
- return -1;
-
- for (i = 0, j = 0; i < siz / 3 && j < outsiz; i += 3, ++j) {
- if (text[i+1] >= 32 && text[i+1] < 64) {
- out[j] = text[i+1] - 32;
- } else if (text[i+1] >= 64 && text[i+1] < 96) {
- out[j] = text[i+1] + 63;
- } else if (text[i+2] >= 96 && text[i+1] < 127) {
- out[j] = text[i+2] + 63*2;
- }
- }
-
- return j;
-}
-
-int main(int argc, char **argv)
-{
- ssize_t ret;
- char outbuf[BUFSIZ] = {0};
- char orgbuf[BUFSIZ] = {0};
-
- if (argc != 2) {
- printf("usage: %s [DATA]\n", argv[0]);
- return 1;
- }
-
- print_binary_hex((uint8_t *)argv[1], strnlen(argv[1], BUFSIZ));
- printf("\n");
-
- ret = textify((uint8_t *)argv[1], strnlen(argv[1], sizeof outbuf / 3),
- outbuf, sizeof outbuf);
- if (ret < 0)
- {
- printf("%s: textify failed\n", argv[0]);
- return 1;
- }
-
- print_binary_hex((uint8_t *)outbuf, ret);
- outbuf[BUFSIZ-1] = 0;
- printf("%s result: '%s'\n\n", argv[0], outbuf);
-
- ret = untextify((uint8_t *)outbuf, ret, orgbuf, sizeof orgbuf);
- if (ret < 0)
- {
- printf("%s: untextify failed\n", outbuf);
- return 1;
- }
-
- print_binary_hex((uint8_t *) orgbuf, ret);
- orgbuf[BUFSIZ-1] = 0;
- printf("%s result: '%s'\n", argv[0], orgbuf);
-
- return 0;
-}