diff --git a/README.md b/README.md index 2b0f468..6ce869c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # c-multicodec multicodec for IPFS in C. + +An implementation of multicodec in C. For the spec, check out https://github.com/multiformats/multicodec + +For an implmentation in go, see https://github.com/multiformats/go-multicodec diff --git a/multicodec.c b/multicodec.c new file mode 100644 index 0000000..6a9fe8f --- /dev/null +++ b/multicodec.c @@ -0,0 +1,9 @@ +#include "multicodec.h" + +int multicodec_encode(const char* codecName, char* inData, size_t inDataLength, char* outData, size_t maxOutDataLength) { + +} + +int multicodec_decode(char* inData, size_t inDataLength, char* outData, size_t maxOutDataLength) { + +} diff --git a/multicodec.h b/multicodec.h new file mode 100644 index 0000000..a371c28 --- /dev/null +++ b/multicodec.h @@ -0,0 +1,35 @@ +/** + * An implementation of multicodec + * See https://github.com/multiformats/multicodec + */ + +#ifndef __MULTICODEC_H__ +#define __MULTICODEC_H__ + +#include + +#define MULTICODEC_RAW_BINARY 0x052f6269632f +#define MULTICODEC_ASCII_BASE_2 0x042f62322f + +/** + * Encode a char array using the specified encoding + * @param codecName a standard name of the codec + * @param inData the incoming data to be encoded + * @param inDataLength the length of the inData + * @param outData a place to store the outgoing data that is at least maxOutDataLength in size + * @param maxOutDataLength the max size for the output + * @returns an error code or 0 if all is well + */ +int multicodec_encode(const char* codecName, char* inData, size_t inDataLength, char* outData, size_t maxOutDataLength); + +/** + * Decode a multicodec encoded data array + * @param inData the data to be decoded + * @param inDataLength the length of the data to be encoded + * @param outData the array to put the results in + * @param maxOutDataLength the maximum size of the data + * @returns an error code or 0 if all is well + */ +int multicodec_decode(char* inData, size_t inDataLength, char* outData, size_t maxOutDataLength); + +#endif // __MULTICODEC_H__