ext/digest/md5/md5init.c


DEFINITIONS

This source file includes following functions.
  1. Init_md5


   1  /* $RoughId: md5init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
   2  /* $Id: md5init.c,v 1.4 2002/09/04 06:37:39 matz Exp $ */
   3  
   4  #include "digest.h"
   5  #include "md5.h"
   6  
   7  static algo_t md5 = {
   8      MD5_DIGEST_LENGTH,
   9      sizeof(MD5_CTX),
  10      (hash_init_func_t)MD5_Init,
  11      (hash_update_func_t)MD5_Update,
  12      (hash_end_func_t)MD5_End,
  13      (hash_final_func_t)MD5_Final,
  14      (hash_equal_func_t)MD5_Equal,
  15  };
  16  
  17  void
  18  Init_md5()
  19  {
  20      VALUE mDigest, cDigest_Base, cDigest_MD5;
  21  
  22      rb_require("digest.so");
  23  
  24      mDigest = rb_path2class("Digest");
  25      cDigest_Base = rb_path2class("Digest::Base");
  26  
  27      cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
  28  
  29      rb_cvar_set(cDigest_MD5, rb_intern("metadata"),
  30                  Data_Wrap_Struct(rb_cObject, 0, 0, &md5), Qtrue);
  31  }