15 #include "../digest.h" 20 bubblebabble_str_new(
VALUE str_digest)
26 size_t i, j, seed = 1;
27 static const char vowels[] = {
28 'a',
'e',
'i',
'o',
'u',
'y' 30 static const char consonants[] = {
31 'b',
'c',
'd',
'f',
'g',
'h',
'k',
'l',
'm',
'n',
32 'p',
'r',
's',
't',
'v',
'z',
'x' 39 if ((
LONG_MAX - 2) / 3 < (digest_len | 1)) {
50 unsigned char byte1, byte2;
52 if (i >= digest_len) {
53 p[j++] = vowels[seed % 6];
54 p[j++] = consonants[16];
55 p[j++] = vowels[seed / 6];
60 p[j++] = vowels[(((byte1 >> 6) & 3) + seed) % 6];
61 p[j++] = consonants[(byte1 >> 2) & 15];
62 p[j++] = vowels[((byte1 & 3) + (seed / 6)) % 6];
64 if (i >= digest_len) {
69 p[j++] = consonants[(byte2 >> 4) & 15];
71 p[j++] = consonants[byte2 & 15];
73 seed = (seed * 5 + byte1 * 7 + byte2) % 36;
89 rb_digest_s_bubblebabble(
VALUE klass,
VALUE str)
91 return bubblebabble_str_new(str);
104 return bubblebabble_str_new(
rb_funcallv(klass, id_digest, argc, argv));
115 rb_digest_instance_bubblebabble(
VALUE self)
117 return bubblebabble_str_new(
rb_funcall(
self, id_digest, 0));
127 VALUE rb_mDigest, rb_mDigest_Instance, rb_cDigest_Class;
143 rb_define_method(rb_mDigest_Instance,
"bubblebabble", rb_digest_instance_bubblebabble, 0);
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
void rb_raise(VALUE exc, const char *fmt,...)
void Init_bubblebabble(void)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_path2class(const char *)
VALUE rb_require(const char *)
RUBY_EXTERN VALUE rb_cObject
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
VALUE rb_define_module_under(VALUE outer, const char *name)
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_new(const char *, long)