key.h

Go to the documentation of this file.
00001 /*
00002 ** $Id: key_8h-source.html,v 1.1 2007/08/02 18:36:20 krishnap Exp $
00003 **
00004 ** Matthew Allen
00005 ** description: 
00006 */
00007 
00008 #ifndef _CHIMERA_KEY_H_
00009 #define _CHIMERA_KEY_H_
00010 
00011 #include <limits.h>
00012 #include <stdio.h>
00013 #include <openssl/evp.h>
00014 #include <string.h>
00015 
00016 #define KEY_SIZE 160
00017 #define BASE_B 4       /* Base representation of key digits */
00018 
00019 typedef struct {
00020   unsigned long t[5];
00021   char keystr[41];     /* string representation of key in hex */
00022  } Key;
00023 
00024 
00025 /* global variables!! that are set in key_init function */
00026 Key Key_Max;
00027 Key Key_Half;
00028 
00029 
00030 /* key_makehash: hashed, s
00031 ** assign sha1 hash of the string #s# to #hashed# */
00032 
00033 void key_makehash(void * logs, Key *hashed, char *s);
00034 
00035 
00036 /* key_init: 
00037 ** initializes Key_Max and Key_Half */
00038 
00039 void key_init();
00040 
00041 /* key_distance:k1,k2
00042 ** calculate the distance between k1 and k2 in the keyspace and assign that to #diff# */
00043 
00044 void key_distance(void * logs, Key *diff, Key k1, Key k2);
00045 
00046  
00047 /* key_between: test, left, right
00048 ** check to see if the value in #test# falls in the range from #left# clockwise
00049 ** around the ring to #right#. */
00050 
00051 int key_between(void * logs, Key test, Key left, Key right);
00052 
00053 
00054 /* key_midpoint: mid, key
00055 ** calculates the midpoint of the namespace from the #key#  */
00056 
00057 void key_midpoint(void * logs, Key *mid, Key key);
00058 
00059 
00060 /* key_index: mykey, key
00061 ** returns the lenght of the longest prefix match between #mykey# and #k# */
00062 
00063 int key_index(void * logs, Key mykey, Key k);
00064 
00065 void key_print(Key k);
00066 
00067 void key_to_str(char *str, Key k);
00068 void str_to_key(char *str, Key *k);
00069 
00070 /* key_assign: k1, k2
00071 ** copies value of #k2# to #k1# */
00072 
00073 void key_assign(Key *k1, Key k2);
00074 
00075 /* key_assign_ui: k1, ul
00076 ** copies #ul# to the least significant 32 bits of #k# */
00077 
00078 void key_assign_ui(Key *k,unsigned long ul);
00079 
00080 /* key_equal:k1, k2 
00081 ** return 1 if #k1#==#k2# 0 otherwise*/
00082 
00083 int key_equal(Key k1,Key k2);
00084 
00085 /* key_equal_ui:k1, ul
00086 ** return 1 if the least significat 32 bits of #k1#==#ul# 0 otherwise */
00087 
00088 int key_equal_ui(Key k, unsigned long ul);
00089 
00090 /*key_comp: k1, k2
00091 ** returns >0 if k1>k2, <0 if k1<k2, and 0 if k1==k2 */
00092 
00093 int key_comp(Key k1, Key k2);
00094 
00095 #endif /* _CHIMERA_KEY_H_ */

Generated on Thu Feb 16 21:42:38 2006 for Chimera by  doxygen 1.4.5