X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftestsuite%2Fhashcalc-plain.c;h=51307081727b8e69c0a30ab49fc531286cbcbed7;hb=09e68ea5be59e9f3824761e9f5ce602b058c458f;hp=16ce2c884ae89680a6f1f61f3e6ca46859654004;hpb=df13e5523df231124858003c93bdaa3b7a361f07;p=util-vserver.git diff --git a/src/testsuite/hashcalc-plain.c b/src/testsuite/hashcalc-plain.c index 16ce2c8..5130708 100644 --- a/src/testsuite/hashcalc-plain.c +++ b/src/testsuite/hashcalc-plain.c @@ -1,16 +1,16 @@ // $Id$ --*- c -*-- // Copyright (C) 2006 Enrico Scholz -// +// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -24,6 +24,7 @@ #include #include #include +#include #include #define ENSC_TESTSUITE @@ -36,19 +37,19 @@ convertDigest(char res[], ensc_hash_context * h_ctx) { static char const HEX_DIGIT[] = "0123456789abcdef"; size_t d_size = ensc_crypto_hashctx_get_digestsize(h_ctx); - + unsigned char digest[d_size]; size_t out = 0; if (ensc_crypto_hashctx_get_digest(h_ctx, digest, NULL, d_size)==-1) return false; - + for (size_t in=0; in> 4]; res[out++] = HEX_DIGIT[digest[in] & 0x0f]; } res[out++] = '\0'; - + return true; } @@ -76,18 +77,18 @@ int main(int UNUSED argc, char *argv[]) void const * buf; if (buf_size>HASH_BLOCKSIZE) buf_size = HASH_BLOCKSIZE; - assert((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))!=0); + assert((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))!=MAP_FAILED); offset += buf_size; assert(ensc_crypto_hashctx_update(&hash_context, buf, buf_size)!=-1); munmap((void *)(buf), buf_size); } - + assert(convertDigest(digest, &hash_context)); - + Vwrite(1, digest, strlen(digest)); Vwrite(1, "\n", 1); - + ensc_crypto_hashctx_free(&hash_context); - + return 0; }