瀏覽代碼

Added macro for base64 decoded size

Evgeny Grin (Karlson2k) 2 年之前
父節點
當前提交
6f80708b75
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      src/microhttpd/mhd_str.h

+ 10 - 0
src/microhttpd/mhd_str.h

@@ -452,6 +452,16 @@ MHD_uint8_to_str_pad (uint8_t val,
 
 #ifdef BAUTH_SUPPORT
 
+/**
+ * Returns the maximum possible size of the Base64 decoded data.
+ * The real recoded size could be up to two bytes smaller.
+ * @param enc_size the size of encoded data, in characters
+ * @return the maximum possible size of the decoded data, in bytes, if
+ *         @a enc_size is valid (properly padded),
+ *         undefined value smaller then @a enc_size if @a enc_size is not valid
+ */
+#define MHD_base64_max_dec_size_(enc_size) (((enc_size) / 4) * 3)
+
 /**
  * Convert Base64 encoded string to binary data.
  * @param base64 the input string with Base64 encoded data, could be NOT zero