pike.git / src / post_modules / Nettle / hash.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/hash.cmod:1:   /* hash.cmod -*- c -*- */      #include "global.h" - RCSID("$Id: hash.cmod,v 1.6 2003/05/08 11:17:17 grubba Exp $"); + RCSID("$Id: hash.cmod,v 1.7 2003/07/29 03:44:39 nilsson Exp $");   #include "interpret.h"   #include "svalue.h"      /* For this_object() */   #include "object.h"   #include "module_support.h"      #include "nettle_config.h"      #ifdef HAVE_LIBNETTLE
pike.git/src/post_modules/Nettle/hash.cmod:163:    Pike_error("Unsupported digest length");       length = arg->u.integer;    }       digest = begin_shared_string(length);    meta->digest(THIS->ctx, length, digest->str);    push_string(end_shared_string(digest));    }    +  /*! @decl string hash(string data) +  *! +  *! Works as a shortcut for @expr{obj->update(data)->digest()@}. +  *! +  *! @note +  *! The hash buffer will not be cleared before @[data] is added +  *! to the buffer, so data added with calls to @[update] will be +  *! prepended to the @[data]. +  *! +  *! @seealso +  *! @[update] and @[digest]. +  */ +  PIKEFUN string hash(string data) { +  f_HashState_update(args); +  pop_stack(); +  f_HashState_digest(0); +  } +     INIT    {    werror("HashState->INIT\n");    THIS->ctx = NULL;    }    EXIT    {    werror("HashState->EXIT\n");    if (THIS->ctx && Pike_fp->current_object->prog)    {
pike.git/src/post_modules/Nettle/hash.cmod:200:    INIT    {    struct HashInfo_struct *HashInfo    = (struct HashInfo_struct *) get_storage(Pike_fp->current_object,    HashInfo_program);       werror("MD5_Info->INIT\n");       if (HashInfo && !HashInfo->meta)    HashInfo->meta = &nettle_md5; -  else +  else {    /* Can't call Pike_error here.    * Pike_error("Can't initialize this object.\n"); */    werror("MD5_Info->INIT failed\n");    }    } -  + }      /*! @endclass MD5_Info */      /*! @class MD5_State    *!    *! State for MD5 hashing.    */   PIKECLASS MD5_State   {    INHERIT MD5_Info;
pike.git/src/post_modules/Nettle/hash.cmod:251:    INIT    {    struct HashInfo_struct *HashInfo    = (struct HashInfo_struct *) get_storage(Pike_fp->current_object,    HashInfo_program);       werror("SHA1_Info->INIT\n");       if (HashInfo && !HashInfo->meta)    HashInfo->meta = &nettle_sha1; -  else +  else {    /* Can't call Pike_error here.    * Pike_error("Can't initialize this object.\n"); */    werror("SHA1_Info->INIT failed\n");    }    } -  + }      /*! @endclass SHA1_Info */      /*! @class SHA1_State    *!    *! State for SHA1 hashing.    */      PIKECLASS SHA1_State   {