X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fvlc_md5.h;h=47f5d0b9e59a0d52a6e15fccb4ea460ebe43f418;hb=1757993049ffe608cd538e2d43aad3cabb68385b;hp=5cd1f9f4cf6660b11302f6b31aaab144f527f8fc;hpb=2cb472dba008f7d877ffe6bae9c5575253365282;p=vlc diff --git a/include/vlc_md5.h b/include/vlc_md5.h index 5cd1f9f4cf..47f5d0b9e5 100644 --- a/include/vlc_md5.h +++ b/include/vlc_md5.h @@ -22,6 +22,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#if !defined( __LIBVLC__ ) + #error You are not libvlc or one of its plugins. You cannot include this file +#endif + #ifndef _VLC_MD5_H # define _VLC_MD5_H @@ -39,8 +43,31 @@ struct md5_s }; VLC_EXPORT(void, InitMD5, ( struct md5_s * ) ); -VLC_EXPORT(void, AddMD5, ( struct md5_s *, const uint8_t *, uint32_t ) ); +VLC_EXPORT(void, AddMD5, ( struct md5_s *, const void *, size_t ) ); VLC_EXPORT(void, EndMD5, ( struct md5_s * ) ); -VLC_EXPORT(void, DigestMD5, ( struct md5_s *, uint32_t * ) ); + +/** + * Returns a char representation of the md5 hash, as shown by UNIX md5 or + * md5sum tools. + */ +static inline char * psz_md5_hash( struct md5_s *md5_s ) +{ + char *psz = malloc( 33 ); /* md5 string is 32 bytes + NULL character */ + if( !psz ) return NULL; + + int i; + for ( i = 0; i < 4; i++ ) + { + sprintf( &psz[8*i], "%02x%02x%02x%02x", + md5_s->p_digest[i] & 0xff, + ( md5_s->p_digest[i] >> 8 ) & 0xff, + ( md5_s->p_digest[i] >> 16 ) & 0xff, + md5_s->p_digest[i] >> 24 + ); + } + psz[32] = '\0'; + + return psz; +} #endif