From 865c545a02ec8740d2796adde8ffe2a6ec849e79 Mon Sep 17 00:00:00 2001 From: "T. von Dein" Date: Mon, 1 Dec 2025 20:42:23 +0100 Subject: [PATCH] move to codeberg (#1) --- .woodpecker/build.yaml | 25 +++++++++ Makefile | 49 +++++++++++++++++ README.md | 7 ++- bubblebabble.c | 121 ++++++++++++++--------------------------- bubblebabble.h | 31 +++++++++++ main.c | 54 ++++++++++++++++++ 6 files changed, 203 insertions(+), 84 deletions(-) create mode 100644 .woodpecker/build.yaml create mode 100644 Makefile create mode 100644 bubblebabble.h create mode 100644 main.c diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..88340c4 --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,25 @@ +matrix: + platform: + - linux/amd64 + +labels: + platform: ${platform} + +steps: + build: + when: + event: [push] + image: alpine:latest + commands: + - apk update + - apk add --no-cache bash build-base + - make + + test: + when: + event: [push] + image: alpine:latest + commands: + - apk update + - apk add --no-cache bash + - echo hier | ./bubblebabble | grep xipak-nynil-dedox diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d868119 --- /dev/null +++ b/Makefile @@ -0,0 +1,49 @@ +# +# This file is part of bubblebabble. +# +# Copyright (C) 2018-2025 T.v.Dein. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# You can contact me by mail: . + +.PHONY: all clean man install + +# warning: do not set -O to 2, see TODO +CFLAGS = -Wall -Wextra -Werror -O1 -g +LDFLAGS= +OBJS = main.o bubblebabble.o +DST = bubblebabble +PREFIX = /usr/local +UID = root +GID = 0 + +all: $(DST) + +$(DST): $(OBJS) + $(CC) $(OBJS) -o $(DST) + +%.o: %.c + $(CC) -c $(CFLAGS) $*.c -o $*.o + +clean: + rm -rf *.o $(DST) build .cache + +man: + pod2man udpxd.pod > udpxd.1 + +install: $(DST) + install -d -o $(UID) -g $(GID) $(PREFIX)/bin + install -o $(UID) -g $(GID) -m 555 $(DST) $(PREFIX)/bin/ + diff --git a/README.md b/README.md index 5c7ab8f..1795089 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # bubblebabble + Encode to Bubble Babble ## Intro @@ -10,8 +11,8 @@ function so you can encode anything to bubble babble. ## Compile and Install - gcc -g bubblebabble.c -o bubblebabble - sudo install -o root -g wheel bubblebabble /usr/local/bin/ + make + sudo make install ## Usage @@ -20,7 +21,7 @@ function so you can encode anything to bubble babble. ## Copyright + Author -- Copyright (c) 2017 T.v.Dein. All rights reserved. +- Copyright (c) 2017-2025 T.v.Dein. All rights reserved. fingerprint_bubblebabble(): diff --git a/bubblebabble.c b/bubblebabble.c index ac1965e..f8430ee 100644 --- a/bubblebabble.c +++ b/bubblebabble.c @@ -30,89 +30,48 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include -#include -#include +#include "bubblebabble.h" -static char * -fingerprint_bubblebabble(u_char *dgst_raw, size_t dgst_raw_len) -{ - char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; - char consonants[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', - 'n', 'p', 'r', 's', 't', 'v', 'z', 'x' }; - u_int i, j = 0, rounds, seed = 1; - char *retval; +char *fingerprint_bubblebabble(u_char *dgst_raw, size_t dgst_raw_len) { + char vowels[] = {'a', 'e', 'i', 'o', 'u', 'y'}; + char consonants[] = {'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', + 'n', 'p', 'r', 's', 't', 'v', 'z', 'x'}; + u_int i, j = 0, rounds, seed = 1; + char *retval; - rounds = (dgst_raw_len / 2) + 1; - if ((retval = calloc(rounds, 6)) == NULL) - return NULL; - retval[j++] = 'x'; - for (i = 0; i < rounds; i++) { - u_int idx0, idx1, idx2, idx3, idx4; - if ((i + 1 < rounds) || (dgst_raw_len % 2 != 0)) { - idx0 = (((((u_int)(dgst_raw[2 * i])) >> 6) & 3) + - seed) % 6; - idx1 = (((u_int)(dgst_raw[2 * i])) >> 2) & 15; - idx2 = ((((u_int)(dgst_raw[2 * i])) & 3) + - (seed / 6)) % 6; - retval[j++] = vowels[idx0]; - retval[j++] = consonants[idx1]; - retval[j++] = vowels[idx2]; - if ((i + 1) < rounds) { - idx3 = (((u_int)(dgst_raw[(2 * i) + 1])) >> 4) & 15; - idx4 = (((u_int)(dgst_raw[(2 * i) + 1]))) & 15; - retval[j++] = consonants[idx3]; - retval[j++] = '-'; - retval[j++] = consonants[idx4]; - seed = ((seed * 5) + - ((((u_int)(dgst_raw[2 * i])) * 7) + - ((u_int)(dgst_raw[(2 * i) + 1])))) % 36; - } - } else { - idx0 = seed % 6; - idx1 = 16; - idx2 = seed / 6; - retval[j++] = vowels[idx0]; - retval[j++] = consonants[idx1]; - retval[j++] = vowels[idx2]; - } - } - retval[j++] = 'x'; - retval[j++] = '\0'; - return retval; -} - - -int main(int argc, char **argv) { - FILE *input; - u_char digest[1024]; - size_t digestlen; - char *hash; - int out = 1; - - if(argc < 2) { - input = stdin; - } - else { - if((input = fopen(argv[1], "rb")) == NULL) { - fprintf(stderr, "oops, could not open file!\n"); - goto done; + rounds = (dgst_raw_len / 2) + 1; + if ((retval = calloc(rounds, 6)) == NULL) + return NULL; + retval[j++] = 'x'; + for (i = 0; i < rounds; i++) { + u_int idx0, idx1, idx2, idx3, idx4; + if ((i + 1 < rounds) || (dgst_raw_len % 2 != 0)) { + idx0 = (((((u_int)(dgst_raw[2 * i])) >> 6) & 3) + seed) % 6; + idx1 = (((u_int)(dgst_raw[2 * i])) >> 2) & 15; + idx2 = ((((u_int)(dgst_raw[2 * i])) & 3) + (seed / 6)) % 6; + retval[j++] = vowels[idx0]; + retval[j++] = consonants[idx1]; + retval[j++] = vowels[idx2]; + if ((i + 1) < rounds) { + idx3 = (((u_int)(dgst_raw[(2 * i) + 1])) >> 4) & 15; + idx4 = (((u_int)(dgst_raw[(2 * i) + 1]))) & 15; + retval[j++] = consonants[idx3]; + retval[j++] = '-'; + retval[j++] = consonants[idx4]; + seed = ((seed * 5) + ((((u_int)(dgst_raw[2 * i])) * 7) + + ((u_int)(dgst_raw[(2 * i) + 1])))) % + 36; + } + } else { + idx0 = seed % 6; + idx1 = 16; + idx2 = seed / 6; + retval[j++] = vowels[idx0]; + retval[j++] = consonants[idx1]; + retval[j++] = vowels[idx2]; } } - - digestlen = fread(digest, 1, 1024, input); - - if(digestlen > 0) { - hash = fingerprint_bubblebabble(digest, digestlen); - fprintf(stdout, "%s\n", hash); - free(hash); - out = 0; - } - else { - fprintf(stderr, "oops, could not calculate bubbles!\n"); - goto done; - } - - done: - return out; + retval[j++] = 'x'; + retval[j++] = '\0'; + return retval; } diff --git a/bubblebabble.h b/bubblebabble.h new file mode 100644 index 0000000..6cd7aaf --- /dev/null +++ b/bubblebabble.h @@ -0,0 +1,31 @@ +/* + This file is part of bubblebabble. + + Copyright (C) 2018-2025 T.v.Dein. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + You can contact me by mail: . +*/ + +#ifndef HAVE_BUBABL +#define HAVE_BUBABL 1 + +#include +#include +#include + +char *fingerprint_bubblebabble(u_char *dgst_raw, size_t dgst_raw_len); + +#endif diff --git a/main.c b/main.c new file mode 100644 index 0000000..d436bf7 --- /dev/null +++ b/main.c @@ -0,0 +1,54 @@ +/* + This file is part of bubblebabble. + + Copyright (C) 2018-2025 T.v.Dein. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + You can contact me by mail: . +*/ + +#include "bubblebabble.h" + +int main(int argc, char **argv) { + FILE *input; + u_char digest[1024]; + size_t digestlen; + char *hash; + int out = 1; + + if (argc < 2) { + input = stdin; + } else { + if ((input = fopen(argv[1], "rb")) == NULL) { + fprintf(stderr, "oops, could not open file!\n"); + goto done; + } + } + + digestlen = fread(digest, 1, 1024, input); + + if (digestlen > 0) { + hash = fingerprint_bubblebabble(digest, digestlen); + fprintf(stdout, "%s\n", hash); + free(hash); + out = 0; + } else { + fprintf(stderr, "oops, could not calculate bubbles!\n"); + goto done; + } + +done: + return out; +}