/* xbt_sha.c - SHA1 hash function */
+/* Copyright (c) 2008-2014. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
/* Initial version part of iksemel (XML parser for Jabber)
* Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>. All right reserved.
* Distributed under LGPL v2.1, February 1999.
*/
/* Later adapted to fit into SimGrid. Distributed under LGPL v2.1, Feb 1999.*/
-/* Copyright (c) 2008-2012. The SimGrid Team.
- * All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
#include "xbt/hash.h"
+#include <stdio.h> /* sprintf */
struct s_xbt_sha_ {
unsigned int hash[5];
/** @brief constructor */
xbt_sha_t xbt_sha_new(void)
{
- xbt_sha_t sha;
-
- sha = xbt_new(s_xbt_sha_t, 1);
+ xbt_sha_t sha = xbt_new(s_xbt_sha_t, 1);
xbt_sha_reset(sha);
-
return sha;
}
/* @brief Add some more data to the buffer */
void xbt_sha_feed(xbt_sha_t sha, const unsigned char *data, size_t len)
{
- int i;
+ unsigned int i;
for (i = 0; i < len; i++) {
sha->buf[sha->blen / 4] <<= 8;
/** @brief returns the sha hash into a newly allocated buffer (+ reset sha object) */
char *xbt_sha_read(xbt_sha_t sha)
{
- char *res = xbt_malloc(40);
+ char *res = xbt_malloc(41);
xbt_sha_print(sha, res);
return res;
}
/* ************* */
#ifdef SIMGRID_TEST
#include "xbt/hash.h"
-#include "portable.h" /* hexa_str */
+#include "src/portable.h" /* hexa_str */
static char *mycmp(const char *p1, const char *p2, size_t n)
{