summaryrefslogtreecommitdiff
path: root/rpmio/rpmbase64.h
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-11-09 15:04:13 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-11-09 15:16:28 +0200
commit70f063cb773bedb7d336429d9bc8ed1d4e5d18f4 (patch)
tree6d525fdbb1e92051dda4b05e5c23fc7f2e531f71 /rpmio/rpmbase64.h
parent6bced5bc08c3c8291fc7488c35e1703cba0f9ef6 (diff)
downloadlibrpm-tizen-70f063cb773bedb7d336429d9bc8ed1d4e5d18f4.tar.gz
librpm-tizen-70f063cb773bedb7d336429d9bc8ed1d4e5d18f4.tar.bz2
librpm-tizen-70f063cb773bedb7d336429d9bc8ed1d4e5d18f4.zip
Make base64 encoding/decoding part of rpmio public API
- Base64 is present in headers and all, it's only reasonable that our API users have access to this functionality without having to link to other libraries. Even if we didn't want to carry the implementation forever in our codebase, we should provide a wrapping for this (much like the other crypto stuff) for the reason stated above. - A bigger issue is that our dirty little (badly hidden) secret was using non-namespaced function names, clashing with at least beecrypt. And we couldn't have made these internal-only symbols even on platforms that support it, because they are used all over the place outside rpmio. So... rename the b64 functions to rpmLikeNamingStyle and make 'em public. No functional changes, just trivial renaming despite touching numerous places.
Diffstat (limited to 'rpmio/rpmbase64.h')
-rw-r--r--rpmio/rpmbase64.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/rpmio/rpmbase64.h b/rpmio/rpmbase64.h
new file mode 100644
index 000000000..95ee9cd03
--- /dev/null
+++ b/rpmio/rpmbase64.h
@@ -0,0 +1,37 @@
+/* base64 encoder/decoder based on public domain implementation
+ * by Chris Venter */
+
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* returns malloced base64 encoded string
+ * lines are split with \n characters to be nearest lower multiple of linelen
+ * if linelen/4 == 0 lines are not split
+ * if linelen < 0 default line length (64) is used
+ * the returned string is empty when len == 0
+ * returns NULL on failures
+ */
+char *rpmBase64Encode(const void *data, size_t len, int linelen);
+
+/* decodes from zero terminated base64 encoded string to a newly malloced buffer
+ * ignores whitespace characters in the input string
+ * return values:
+ * 0 - OK
+ * 1 - input is NULL
+ * 2 - invalid length
+ * 3 - invalid characters on input
+ * 4 - malloc failed
+ */
+int rpmBase64Decode(const char *in, void **out, size_t *outlen);
+
+/* counts CRC24 and base64 encodes it in a malloced string
+ * returns NULL on failures
+ */
+char *rpmBase64CRC(const unsigned char *data, size_t len);
+
+#ifdef __cplusplus
+}
+#endif