From 6b438e75172781f94821ea49b7cfc120dbb650b3 Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Sat, 11 Mar 2017 15:11:17 -0800 Subject: [PATCH] encoder: further simplifications Get rid of unique header files for each encoder, consolidate them to where they are actually needed: encoding.h. This also simplifies the generation of the base64u decoder, as its header file does not need to be generated any longer. Signed-off-by: Ralf Ramsauer --- src/Makefile | 6 +----- src/base128.c | 1 - src/base128.h | 22 ---------------------- src/base32.c | 1 - src/base32.h | 25 ------------------------- src/base64.c | 1 - src/base64.h | 23 ----------------------- src/client.c | 4 ---- src/encoding.h | 20 +++++++++++++++++--- src/iodined.c | 4 ---- 10 files changed, 18 insertions(+), 89 deletions(-) delete mode 100644 src/base128.h delete mode 100644 src/base32.h delete mode 100644 src/base64.h diff --git a/src/Makefile b/src/Makefile index 9026318..f08ff78 100644 --- a/src/Makefile +++ b/src/Makefile @@ -32,15 +32,11 @@ $(SERVER): $(COMMONOBJS) $(SERVEROBJS) @echo CC $< @$(CC) $(CFLAGS) $< -o $@ -base64u.o client.o iodined.o: base64u.h +base64u.o client.o iodined.o: base64u.c: base64.c @echo Making $@ @echo '/* No use in editing, produced by Makefile! */' > $@ @sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.c >> $@ -base64u.h: base64.h - @echo Making $@ - @echo '/* No use in editing, produced by Makefile! */' > $@ - @sed -e 's/\([Bb][Aa][Ss][Ee]64\)/\1u/g ; s/0123456789+/0123456789_/' < base64.h >> $@ clean: @echo "Cleaning src/" diff --git a/src/base128.c b/src/base128.c index 30b6034..7c3520e 100644 --- a/src/base128.c +++ b/src/base128.c @@ -33,7 +33,6 @@ #include #include "encoding.h" -#include "base128.h" #define BLKSIZE_RAW 7 #define BLKSIZE_ENC 8 diff --git a/src/base128.h b/src/base128.h deleted file mode 100644 index f967134..0000000 --- a/src/base128.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2009 J.A.Bezemer@opensourcepartners.nl - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __BASE128_H__ -#define __BASE128_H__ - -const struct encoder base128_ops; - -#endif diff --git a/src/base32.c b/src/base32.c index 809115a..e35867f 100644 --- a/src/base32.c +++ b/src/base32.c @@ -21,7 +21,6 @@ #include #include "encoding.h" -#include "base32.h" #define BLKSIZE_RAW 5 #define BLKSIZE_ENC 8 diff --git a/src/base32.h b/src/base32.h deleted file mode 100644 index 89f78ad..0000000 --- a/src/base32.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2006-2014 Erik Ekman , - * 2006-2009 Bjorn Andersson - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __BASE32_H__ -#define __BASE32_H__ - -int b32_5to8(int); -int b32_8to5(int); - -extern const struct encoder base32_ops; -#endif diff --git a/src/base64.c b/src/base64.c index 875c8c9..525e4dc 100644 --- a/src/base64.c +++ b/src/base64.c @@ -21,7 +21,6 @@ #include #include "encoding.h" -#include "base64.h" #define BLKSIZE_RAW 3 #define BLKSIZE_ENC 4 diff --git a/src/base64.h b/src/base64.h deleted file mode 100644 index 376ea2d..0000000 --- a/src/base64.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2006-2014 Erik Ekman , - * 2006-2009 Bjorn Andersson - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __BASE64_H__ -#define __BASE64_H__ - -extern const struct encoder base64_ops; - -#endif diff --git a/src/client.c b/src/client.c index db792c1..7f33654 100644 --- a/src/client.c +++ b/src/client.c @@ -47,10 +47,6 @@ #include "common.h" #include "encoding.h" -#include "base32.h" -#include "base64.h" -#include "base64u.h" -#include "base128.h" #include "dns.h" #include "login.h" #include "tun.h" diff --git a/src/encoding.h b/src/encoding.h index a75a312..e0070a1 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -1,6 +1,12 @@ /* - * Copyright (c) 2006-2014 Erik Ekman , - * 2006-2009 Bjorn Andersson + * Copyright (c) 2006-2014 Erik Ekman + * 2006-2009 Bjorn Andersson + * Copyright (c) 2017 Ralf Ramsauer + * + * Authors: + * Bjorn Andersson + * Erok Ekman , + * Ralf Ramsauer * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -40,4 +46,12 @@ int unpack_data(char *, size_t, char *, size_t, const struct encoder *); int inline_dotify(char *, size_t); int inline_undotify(char *, size_t); -#endif /* _ENCODING_H_ */ +extern const struct encoder base32_ops; +extern const struct encoder base64_ops; +extern const struct encoder base64u_ops; +extern const struct encoder base128_ops; + +int b32_5to8(int); +int b32_8to5(int); + +#endif diff --git a/src/iodined.c b/src/iodined.c index 534325f..4ba20fd 100644 --- a/src/iodined.c +++ b/src/iodined.c @@ -51,10 +51,6 @@ #include "dns.h" #include "encoding.h" -#include "base32.h" -#include "base64.h" -#include "base64u.h" -#include "base128.h" #include "user.h" #include "login.h" #include "tun.h"