Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "EGlib.h"
00030
00031
00032 static int nkeys = 100;
00033 static int nlookup = 1000;
00034
00035
00036 void keytab_usage(char*program)
00037 {
00038 fprintf(stdout,"Usage: %s [options]\n",program);
00039 fprintf(stdout,"Options:\n\t-n n number of keys to generate\n");
00040 fprintf(stdout,"\t-l n number of keys to lookup\n");
00041 }
00042
00043
00044 int keytab_parse(int argc,char**argv)
00045 {
00046 int c;
00047 while((c = getopt(argc,argv,"l:n:")) != EOF)
00048 {
00049 switch(c)
00050 {
00051 case 'l':
00052 nlookup = atoi(optarg);
00053 break;
00054 case 'n':
00055 nkeys = atoi(optarg);
00056 break;
00057 default:
00058 keytab_usage(argv[0]);
00059 return 1;
00060 }
00061 }
00062 return 0;
00063 }
00064
00065
00066 int main (int argc,char**argv)
00067 {
00068 int rval=0,i,pos;
00069 uint64_t key;
00070 EGrandState_t g1;
00071 EGkeytab_t keytab;
00072 EGlib_info();
00073 EGlib_version();
00074 EGrandInit(&g1);
00075 EGkeytabInit(&keytab);
00076 rval = keytab_parse(argc,argv);
00077 CHECKRVALG(rval,CLEANUP);
00078
00079 EGsigSet(rval,CLEANUP);
00080 EGsetLimits(3600.0,4294967295UL);
00081
00082 for( i = 0 ; i < nkeys ; i++)
00083 {
00084 key = EGrand(&g1);
00085 key = key << 32;
00086 key = EGrand(&g1);
00087 rval = EGkeytabAdd( &keytab, key, 1);
00088 rval = 0;
00089 }
00090 for( i = 0 ; i < nlookup ; i++)
00091 {
00092 key = EGrand(&g1);
00093 key = key << 32;
00094 key = EGrand(&g1);
00095 if(EGkeytabLookUp(&keytab,key,&pos))
00096 fprintf(stdout,"Found key %"PRIu64" in position %d\n",key,pos);
00097 }
00098 CLEANUP:
00099 EGkeytabClear(&keytab);
00100 return rval;
00101 }
00102
00103