size_t yang_dnode_get_binary_buf(char *buf, size_t size,
				 const struct lyd_node *dnode,
				 const char *xpath_fmt, ...)
{
	const char *canon;
	size_t cannon_len;
	size_t decode_len;
	size_t ret_len;
	size_t cnt;
	char *value_str;
	struct base64_decodestate s;

	canon = YANG_DNODE_XPATH_GET_CANON(dnode, xpath_fmt);
	cannon_len = strlen(canon);
	decode_len = cannon_len;
	value_str = (char *)malloc(decode_len);
	base64_init_decodestate(&s);
	cnt = base64_decode_block(canon, cannon_len, value_str, &s);

	ret_len = size > cnt ? cnt : size;
	memcpy(buf, value_str, ret_len);
	if (size < cnt) {
		char xpath[XPATH_MAXLEN];

		yang_dnode_get_path(dnode, xpath, sizeof(xpath));
		flog_warn(EC_LIB_YANG_DATA_TRUNCATED,
			  "%s: value was truncated [xpath %s]", __func__,
			  xpath);
	}
	free(value_str);
	return ret_len;
}
size_t yang_dnode_get_binary_buf(char *buf, size_t size,
				 const struct lyd_node *dnode,
				 const char *xpath_fmt, ...)
{
	const char *canon;
	size_t cannon_len;
	size_t decode_len;
	size_t ret_len;
	size_t cnt;
	char *value_str;
	struct base64_decodestate s;

	canon = YANG_DNODE_XPATH_GET_CANON(dnode, xpath_fmt);
	cannon_len = strlen(canon);
	decode_len = cannon_len;
	value_str = (char *)malloc(decode_len);
	base64_init_decodestate(&s);
	cnt = base64_decode_block(canon, cannon_len, value_str, &s);

	ret_len = size > cnt ? cnt : size;
	memcpy(buf, value_str, ret_len);
	if (size < cnt) {
		char xpath[XPATH_MAXLEN];

		yang_dnode_get_path(dnode, xpath, sizeof(xpath));
		flog_warn(EC_LIB_YANG_DATA_TRUNCATED,
			  "%s: value was truncated [xpath %s]", __func__,
			  xpath);
	}
	free(value_str);
	return ret_len;
}