OpenSSL VPN Serveurs de messagerie |
APR/APR-mmap-md5
#include "apr_mmap.h" #include "apr_strings.h" #include "apr_file_io.h" #include "apr_md5.h" int main(int argc, char* argv[]) { apr_md5_ctx_t md5_ctx; apr_md5_init(&md5_ctx); unsigned char digest[APR_MD5_DIGESTSIZE]; static apr_mmap_t *themmap = NULL; static apr_file_t *thefile = NULL; static apr_finfo_t finfo; apr_status_t rv; apr_pool_t *p; apr_initialize(); apr_pool_create(&p, NULL); static char file1[]="c:\\Arte - 27-12-2006 13h58 1h20m.mpg"; rv = apr_file_open(&thefile, file1, APR_READ, APR_UREAD | APR_GREAD, p); apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile); apr_off_t offset=0; apr_size_t RemainingSize=(apr_size_t)finfo.size; apr_size_t ReadedSize=0; while(RemainingSize>0){ offset+=ReadedSize; if(RemainingSize>APR_MMAP_LIMIT){ ReadedSize = APR_MMAP_LIMIT; } else{ ReadedSize = RemainingSize; } rv = apr_mmap_create(&themmap, thefile, offset, ReadedSize, APR_MMAP_READ, p); apr_md5_update(&md5_ctx,(char*)themmap->mm,ReadedSize); rv = apr_mmap_delete(themmap); RemainingSize-=ReadedSize; }; apr_md5_final(digest,&md5_ctx); apr_file_close(thefile); apr_pool_destroy(p); for (int di = 0; di < 16; ++di) printf("%02x", digest[di]); return 0; } |