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.2 2003/03/18 13:35:31 nisse Exp $"); + RCSID("$Id: hash.cmod,v 1.3 2003/03/18 15:29:56 nisse 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:30:    va_list args;       va_start(args, format);    vfprintf(stderr, format, args);    va_end(args);   }   #else   #define werror(x)   #endif    + /*! @module Nettle */ +    /*! @class HashInfo    *!    *! Represents information about a hash algorithm, such as    *! name, digest size, and internal block size.    */   PIKECLASS HashInfo   {    CVAR const struct nettle_hash *meta;       /*! @decl string name(void)
pike.git/src/post_modules/Nettle/hash.cmod:81:       push_int(THIS->meta->block_size);    }    INIT    {    werror("HashInfo->INIT\n");    THIS->meta = NULL;    }   }    + /*! @endclass HashInfo */ +    #define GET_META(o) \   ( ((struct HashInfo_struct *) get_storage((o), HashInfo_program)) \    ->meta)      /* The algorithm objects have to be implemented in pike. */      /*! @class HashState    *!    *! Base class for hashing contexts.    */
pike.git/src/post_modules/Nettle/hash.cmod:175:    werror("HashState->EXIT\n");    if (THIS->ctx)    {    const struct nettle_hash *meta = GET_META(this_object());    assert(meta);    memset(THIS->ctx, 0, meta->context_size);    }    }   }    + /*! @endclass HashState */ +    /*! @class MD5_Info    *!    *! Internal mixin class, intended to be multiply inherited    *! together with HashInfo. */      PIKECLASS MD5_Info   {    INIT    {    struct HashInfo_struct *HashInfo    = (struct HashInfo_struct *) get_storage(this_object(),    HashInfo_program);       werror("MD5_Info->INIT\n");    -  if (HashInfo || !HashInfo->meta) +  if (HashInfo && !HashInfo->meta)    HashInfo->meta = &nettle_md5;    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;    INHERIT HashState;    CVAR struct md5_ctx md5;   
pike.git/src/post_modules/Nettle/hash.cmod:222:    = (struct HashState_struct *) get_storage(this_object(),    HashState_program);    werror("MD5_State->INIT\n");       assert(instance);       md5_init(&THIS->md5);    instance->ctx = &THIS->md5;    }   } + /*! @endclass MD5_State */      /*! @class SHA1_Info    *!    *! Internal mixin class, intended to be multiply inherited    *! together with HashInfo. */      PIKECLASS SHA1_Info   {    INIT    {    struct HashInfo_struct *HashInfo    = (struct HashInfo_struct *) get_storage(this_object(),    HashInfo_program);       werror("SHA1_Info->INIT\n");    -  if (HashInfo || !HashInfo->meta) +  if (HashInfo && !HashInfo->meta)    HashInfo->meta = &nettle_sha1;    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   {    INHERIT SHA1_Info;    INHERIT HashState;    CVAR struct sha1_ctx sha1;
pike.git/src/post_modules/Nettle/hash.cmod:271:    = (struct HashState_struct *) get_storage(this_object(),    HashState_program);    werror("SHA1_State->INIT\n");       assert(instance);       sha1_init(&THIS->sha1);    instance->ctx = &THIS->sha1;    }   } + /*! @endclass SHA1_State */    -  + /*! @endmodule Nettle */      void   hash_init(void)   {    werror("Nettle, hash init\n");    INIT;   }      void   hash_exit(void)   {    werror("Nettle, hash exit\n");    EXIT;   }      #endif /* HAVE_LIBNETTLE */