aboutsummaryrefslogtreecommitdiffstats
path: root/librecrypt_get_encoding.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-04-26 22:36:47 +0200
committerMattias Andrée <m@maandree.se>2026-04-26 22:36:47 +0200
commitd77ab463184d113ca6119403887c9f4ed0dfdf0b (patch)
treeca8a1de443f90a4b7def56ea5b61c96aaa949f45 /librecrypt_get_encoding.c
downloadlibrecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.gz
librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.bz2
librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.xz
First commit
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
-rw-r--r--librecrypt_get_encoding.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/librecrypt_get_encoding.c b/librecrypt_get_encoding.c
new file mode 100644
index 0000000..dd5d33d
--- /dev/null
+++ b/librecrypt_get_encoding.c
@@ -0,0 +1,46 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+const void *
+librecrypt_get_encoding(const char *settings, size_t len, char *pad_out, int *strict_pad_out, int decoding)
+{
+ size_t i, start = 0u;
+ const struct algorithm *algo;
+
+ for (i = 0u; i < len; i++)
+ if (settings[i] == LIBRECRYPT_ALGORITHM_LINK_DELIMITER)
+ start = i + 1u;
+ settings = &settings[start];
+ len -= start;
+
+ algo = librecrypt_find_first_algorithm_(settings, len);
+ if (!algo) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ *pad_out = algo->pad;
+ *strict_pad_out = algo->strict_pad;
+ if (decoding)
+ return algo->decoding_lut;
+ else
+ return algo->encoding_lut;
+}
+
+
+#else
+
+
+int
+main(void)
+{
+ SET_UP_ALARM();
+
+ return 0;
+}
+
+
+#endif
+/* TODO test */