ext/ezmlm/hash/hash.h
author Mahlon E. Smith <mahlon@laika.com>
Tue, 16 May 2017 13:58:34 -0700
changeset 17 23c7f5c8ee39
parent 16 e135ccae6783
child 23 eedb2586dea4
permissions -rw-r--r--
Multiple changes. - Remove the runtime dependency on rake-compiler. - Use #rb_str_new instead of #rb_str_new2, the hash character array isn't null terminated. - Add various safeguards for object instantiations. - Remove the 'threaded' options for messages, folding them into 'archived'. If archiving is enabled, so is threading. - Return nil for lookups from the list object instead of raising exceptions. - Open subject indexes with the proper encodings (thanks Michael Granger!) - Allow touching and unlinking files to operate on multiple paths at once, within a single safety() wrap.


#include <ruby.h>

static VALUE rb_mEzmlm;
static VALUE rb_cEZHash;


#ifndef SURF_H
#define SURF_H

#define ROTATE(x,b) (((x) << (b)) | ((x) >> (32 - (b))))
#define MUSH(i,b) x = t[i] += (((x ^ seed[i]) + sum) ^ ROTATE(x,b));

typedef struct {
	unsigned int seed[32];
	unsigned int sum[8];
	unsigned int out[8];
	unsigned int in[12];
	int todo;
} surfpcs;

static const unsigned int littleendian[8] = {
  0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c,
  0x13121110, 0x17161514, 0x1b1a1918, 0x1f1e1d1c
} ;
#define end ((unsigned char *) &littleendian)
#define data ((unsigned char *) s->in)
#define outdata ((unsigned char *) s->out)

extern void surf( unsigned int out[8], const unsigned int in[12], const unsigned int seed[32] );
extern void surfpcs_init( surfpcs *s, const unsigned int k[32] );
extern void surfpcs_add( surfpcs *s, const char *x,unsigned int n );
extern void surfpcs_addlc( surfpcs *s, const char *x,unsigned int n );
extern void surfpcs_out( surfpcs *s, unsigned char h[32] );
#endif


#ifndef SUBHASH_H
#define SUBHASH_H

unsigned int subhashs(const char *s);
unsigned int subhashb(const char *s,long len);
#define subhashsa(SA) subhashb((SA)->s,(SA)->len)

#endif