aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2019-11-11 20:22:09 +0100
committerToni Uhlig <matzeton@googlemail.com>2019-11-11 20:22:09 +0100
commitdb6dd292499cb8f824d951c3734e305e0cc4470d (patch)
tree417a0fe296882559a2f3d42b1a543ae6d967246c
parent8ba7ce41445ba1cf8173152dee162411e98f3960 (diff)
removed obsolete textify tool
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--Makefile15
-rw-r--r--textify.c123
2 files changed, 4 insertions, 134 deletions
diff --git a/Makefile b/Makefile
index ce4d66a..c13c337 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ CFLAGS := -O2 -g -Wall -ffunction-sections -fdata-sections -ffast-math -fomit-fr
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
@@ -42,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'
@@ -81,9 +74,9 @@ strip:
strip -s $(TARGETS)
clean:
- -$(RM) aes.o asciihexer.o dummyshell.o gol.o suidcmd.o ascii85.o textify.o progressbar.o xidle.o xdiff.o
- -$(RM) aes.d asciihexer.d dummyshell.d gol.d suidcmd.d scrambler.d textify.d progressbar.d xidle.d xdiff.d
- -$(RM) aes asciihexer dummyshell gol suidcmd scrambler textify progressbar 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)
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;
-}