dd10eb1997-03-04Niels Möller /* Crypto.pmod * */
a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
a20af62000-09-26Fredrik Hübinette (Hubbe) 
bc57c12002-06-07Martin Nilsson private mixed crypto_module;
dd10eb1997-03-04Niels Möller 
bc57c12002-06-07Martin Nilsson static mixed `[](string name)
dd10eb1997-03-04Niels Möller {
a38c352002-10-16Martin Nilsson  mixed err = catch {
e424aa1997-11-19Fredrik Hübinette (Hubbe)  return (crypto_module[name]
7fa6bc2002-07-16Per Hedbor  || ((program) combine_path( __FILE__, "..", "Crypto" , name + ".pike")) || ((object) combine_path( __FILE__, "..","Crypto", name + ".pmod")));
1ee6941997-05-30Henrik Grubbström (Grubba)  };
a38c352002-10-16Martin Nilsson  if( file_stat("Crypto/"+name) || file_stat("Crypto/"+name+".pmod") ) throw(err);
5519b22002-02-14Martin Nilsson  return UNDEFINED;
dd10eb1997-03-04Niels Möller }
bc57c12002-06-07Martin Nilsson private array(string) crypto_indices;
5519b22002-02-14Martin Nilsson 
bc57c12002-06-07Martin Nilsson static array(string) _indices() {
5519b22002-02-14Martin Nilsson  if(crypto_indices) return crypto_indices + ({});
cf5d562001-11-05Martin Nilsson  array tmp = ( __FILE__ / "/"); tmp[-1] = "Crypto"; tmp = get_dir(tmp*"/");
5519b22002-02-14Martin Nilsson  crypto_indices = map(glob("*.pike",tmp)+glob("*.pmod",tmp), lambda(string in){ return in[..sizeof(in)-6]; }) +
cf5d562001-11-05Martin Nilsson  indices(crypto_module);
5519b22002-02-14Martin Nilsson  return crypto_indices + ({});
cf5d562001-11-05Martin Nilsson }
bc57c12002-06-07Martin Nilsson static void create()
e424aa1997-11-19Fredrik Hübinette (Hubbe) {
5519b22002-02-14Martin Nilsson #if constant(_Crypto)
7fa6bc2002-07-16Per Hedbor  crypto_module = _Crypto;
5519b22002-02-14Martin Nilsson #else
7fa6bc2002-07-16Per Hedbor  crypto_module = _Lobotomized_Crypto;
5519b22002-02-14Martin Nilsson #endif
e424aa1997-11-19Fredrik Hübinette (Hubbe) }