pike.git/
src/
post_modules/
Nettle/
hash.H
Branch:
Tag:
Non-build tags
All tags
No tags
2011-12-20
2011-12-20 16:43:28 by Henrik Grubbström (Grubba) <grubba@grubba.org>
88064b688b9bdb71b06921352c33166ba3b25ef1 (
58
lines) (+
58
/-
0
)
[
Show
|
Annotate
]
Branch:
7.9
Nettle: Parameterized hash.cmod by using cmod API level 4.
1:
+
/* -*- C -*-
+
*
+
* Cmod header-file acting as a template for the hash classes.
+
*/
-
+
DOCSTART() @class cmod_CONCAT_EVAL(PIKE_NAME, _Info)
+
*!
+
*! Internal mixin class, intended to be multiply inherited
+
*! together with HashInfo.
+
DOCEND()
+
PIKECLASS cmod_CONCAT_EVAL(PIKE_NAME, _Info)
+
{
+
INIT
+
{
+
struct HashInfo_struct *HashInfo
+
= (struct HashInfo_struct *) get_storage(Pike_fp->current_object,
+
HashInfo_program);
+
+
werror(cmod_STRFY_EVAL(PIKE_NAME) "_Info->INIT\n");
+
+
if (HashInfo && !HashInfo->meta)
+
HashInfo->meta = &cmod_CONCAT_EVAL(nettle_, NETTLE_NAME);
+
else {
+
/* Can't call Pike_error here.
+
* Pike_error("Can't initialize this object.\n"); */
+
werror(cmod_STRFY_EVAL(PIKE_NAME) "_Info->INIT failed\n");
+
}
+
}
+
}
+
+
DOCSTART() @endclass cmod_CONCAT_EVAL(PIKE_NAME, _Info)
+
DOCEND()
+
+
DOCSTART() @class cmod_CONCAT_EVAL(PIKE_NAME, _State)
+
*!
+
*! State for PIKE_NAME hashing.
+
DOCEND()
+
PIKECLASS cmod_CONCAT_EVAL(PIKE_NAME, _State)
+
{
+
INHERIT cmod_CONCAT_EVAL(PIKE_NAME, _Info);
+
INHERIT HashState;
+
CVAR struct cmod_CONCAT_EVAL(NETTLE_NAME, _ctx) NETTLE_NAME;
+
+
INIT
+
{
+
struct HashState_struct *instance
+
= (struct HashState_struct *) get_storage(Pike_fp->current_object,
+
HashState_program);
+
werror(cmod_STRFY_EVAL(PIKE_NAME) "_State->INIT\n");
+
+
assert(instance);
+
+
cmod_CONCAT_EVAL(NETTLE_NAME, _init)(&THIS->NETTLE_NAME);
+
instance->ctx = &THIS->NETTLE_NAME;
+
}
+
}
+
DOCSTART() @endclass cmod_CONCAT_EVAL(PIKE_NAME, _State)
+
DOCEND()
Newline at end of file added.