* ext/digest/digest.c (rb_digest_base_reset, Init_digest): Add
Digest::Base#reset. * ext/digest/digest.h: Update the header comment. * ext/digest/md5/md5ossl.h, ext/digest/md5/md5init.c (Init_md5): Define DIGEST_LENGTH and BLOCK_LENGTH. * ext/digest/rmd160/rmd160init.c (Init_rmd160): Ditto. * ext/digest/sha1/sha1init.c (Init_sha1): Ditto. * ext/digest/sha2/sha2init.c (Init_sha2): Ditto. * ext/digest/depend, ext/digest/extconf.rb: Use $INSTALLFILES rather than adding make targets. [Pointed out by: nobu] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
55b9887f97
commit
cd58f3313e
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
Wed Oct 11 14:03:31 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/digest/digest.c (rb_digest_base_reset, Init_digest): Add
|
||||
Digest::Base#reset.
|
||||
|
||||
* ext/digest/digest.h: Update the header comment.
|
||||
|
||||
* ext/digest/md5/md5ossl.h, ext/digest/md5/md5init.c (Init_md5):
|
||||
Define DIGEST_LENGTH and BLOCK_LENGTH.
|
||||
|
||||
* ext/digest/rmd160/rmd160init.c (Init_rmd160): Ditto.
|
||||
|
||||
* ext/digest/sha1/sha1init.c (Init_sha1): Ditto.
|
||||
|
||||
* ext/digest/sha2/sha2init.c (Init_sha2): Ditto.
|
||||
|
||||
* ext/digest/depend, ext/digest/extconf.rb: Use $INSTALLFILES
|
||||
rather than adding make targets. [Pointed out by: nobu]
|
||||
|
||||
Tue Oct 10 16:39:08 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/digest/digest.c (hexdigest_str_new, bubblebabble_str_new):
|
||||
|
@ -1,8 +1,2 @@
|
||||
digest.o: digest.c digest.h $(hdrdir)/ruby.h $(topdir)/config.h \
|
||||
$(hdrdir)/defines.h $(hdrdir)/intern.h
|
||||
|
||||
install-so: install-h
|
||||
site-install-so: install-h
|
||||
|
||||
install-h:
|
||||
$(INSTALL_DATA) $(srcdir)/digest.h $(RUBYARCHDIR)
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "digest.h"
|
||||
|
||||
static VALUE mDigest, cDigest_Base;
|
||||
static ID id_metadata, id_new, id_update, id_digest;
|
||||
static ID id_metadata, id_new, id_reset, id_update, id_digest;
|
||||
|
||||
/*
|
||||
* Digest::Base
|
||||
@ -221,6 +221,28 @@ rb_digest_base_copy(VALUE copy, VALUE obj)
|
||||
return copy;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_digest_base_reset(VALUE self)
|
||||
{
|
||||
algo_t *algo;
|
||||
void *pctx;
|
||||
|
||||
algo = get_digest_base_metadata(rb_obj_class(self));
|
||||
|
||||
if (algo == NULL) {
|
||||
rb_funcall(self, id_reset, 0);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
Data_Get_Struct(self, void, pctx);
|
||||
|
||||
memset(pctx, 0, algo->ctx_size);
|
||||
algo->init_func(pctx);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_digest_base_update(VALUE self, VALUE str)
|
||||
{
|
||||
@ -407,6 +429,7 @@ Init_digest(void)
|
||||
|
||||
rb_define_method(cDigest_Base, "initialize", rb_digest_base_init, -1);
|
||||
rb_define_method(cDigest_Base, "initialize_copy", rb_digest_base_copy, 1);
|
||||
rb_define_method(cDigest_Base, "reset", rb_digest_base_reset, 0);
|
||||
rb_define_method(cDigest_Base, "update", rb_digest_base_update, 1);
|
||||
rb_define_method(cDigest_Base, "<<", rb_digest_base_lshift, 1);
|
||||
rb_define_method(cDigest_Base, "digest", rb_digest_base_digest, 0);
|
||||
@ -418,6 +441,7 @@ Init_digest(void)
|
||||
|
||||
id_metadata = rb_intern("metadata");
|
||||
id_new = rb_intern("new");
|
||||
id_reset = rb_intern("reset");
|
||||
id_update = rb_intern("update");
|
||||
id_digest = rb_intern("digest");
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/************************************************
|
||||
|
||||
digest.c -
|
||||
digest.h - header file for ruby digest modules
|
||||
|
||||
$Author$
|
||||
created at: Fri May 25 08:54:56 JST 2001
|
||||
|
||||
|
||||
Copyright (C) 2001 Akinori MUSHA
|
||||
Copyright (C) 2001-2006 Akinori MUSHA
|
||||
|
||||
$RoughId: digest.h,v 1.3 2001/07/13 15:38:27 knu Exp $
|
||||
$Id$
|
||||
|
@ -3,4 +3,8 @@
|
||||
|
||||
require "mkmf"
|
||||
|
||||
$INSTALLFILES = {
|
||||
"digest.h" => "$(RUBYARCHDIR)"
|
||||
}
|
||||
|
||||
create_makefile("digest")
|
||||
|
@ -29,6 +29,9 @@ Init_md5()
|
||||
|
||||
cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
|
||||
|
||||
rb_define_const(cDigest_MD5, "DIGEST_LENGTH", INT2NUM(MD5_DIGEST_LENGTH));
|
||||
rb_define_const(cDigest_MD5, "BLOCK_LENGTH", INT2NUM(MD5_BLOCK_LENGTH));
|
||||
|
||||
rb_cvar_set(cDigest_MD5, rb_intern("metadata"),
|
||||
Data_Wrap_Struct(rb_cObject, 0, 0, &md5), Qtrue);
|
||||
}
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <stddef.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#define MD5_BLOCK_LENGTH MD5_CBLOCK
|
||||
|
||||
void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
|
||||
int MD5_Equal(MD5_CTX *pctx1, MD5_CTX *pctx2);
|
||||
|
||||
|
@ -30,6 +30,9 @@ Init_rmd160()
|
||||
|
||||
cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
|
||||
|
||||
rb_define_const(cDigest_RMD160, "DIGEST_LENGTH", INT2NUM(RMD160_DIGEST_LENGTH));
|
||||
rb_define_const(cDigest_RMD160, "BLOCK_LENGTH", INT2NUM(RMD160_BLOCK_LENGTH));
|
||||
|
||||
id_metadata = rb_intern("metadata");
|
||||
|
||||
rb_cvar_set(cDigest_RMD160, id_metadata,
|
||||
|
@ -29,6 +29,9 @@ Init_sha1()
|
||||
|
||||
cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
|
||||
|
||||
rb_define_const(cDigest_SHA1, "DIGEST_LENGTH", INT2NUM(SHA1_DIGEST_LENGTH));
|
||||
rb_define_const(cDigest_SHA1, "BLOCK_LENGTH", INT2NUM(SHA1_BLOCK_LENGTH));
|
||||
|
||||
rb_cvar_set(cDigest_SHA1, rb_intern("metadata"),
|
||||
Data_Wrap_Struct(rb_cObject, 0, 0, &sha1), Qtrue);
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ Init_sha2()
|
||||
|
||||
#define DEFINE_ALGO_CLASS(bitlen) \
|
||||
cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
|
||||
\
|
||||
rb_define_const(cDigest_SHA##bitlen, "DIGEST_LENGTH", INT2NUM(SHA##bitlen##_DIGEST_LENGTH)); \
|
||||
rb_define_const(cDigest_SHA##bitlen, "BLOCK_LENGTH", INT2NUM(SHA##bitlen##_BLOCK_LENGTH)); \
|
||||
\
|
||||
rb_cvar_set(cDigest_SHA##bitlen, id_metadata, \
|
||||
Data_Wrap_Struct(rb_cObject, 0, 0, &sha##bitlen), Qtrue);
|
||||
|
Loading…
x
Reference in New Issue
Block a user