19 #define INDEX_KEYSIZE 177
26 key(
const char *keyid,
const char *keyhash);
32 static memalloc private_cache;
34 static condlock_t private_lock;
36 key::key(
const char *keyid,
const char *keyhash) :
39 id = private_cache.dup(keyid);
40 hash = private_cache.dup(keyhash);
45 private_lock.modify();
46 memset(private_paths, 0,
sizeof(private_paths));
47 private_cache.purge();
48 private_lock.commit();
56 private_lock.access();
58 linked_pointer<key> keys = private_paths[path];
60 if(String::equal(
id, keys->id))
64 private_lock.release();
71 private_lock.release();
76 assert(
id != NULL && hash != NULL);
79 size_t len = strlen(hash);
81 private_lock.access();
83 linked_pointer<key> keys = private_paths[path];
85 if(String::equal(
id, keys->id)) {
86 if(len == strlen(keys->hash)) {
87 String::set(keys->hash, ++len, hash);
88 private_lock.commit();
95 mp = private_cache.alloc(
sizeof(
key));
96 new(mp)
key(
id, hash);
97 private_lock.commit();
107 dir::create(DEFAULT_VARPATH
"/lib/sipwitch/digests", fsys::GROUP_PRIVATE);
109 fp = fopen(*path,
"r");
114 while(NULL != fgets(buffer,
sizeof(buffer), fp)) {
118 cp = strchr(buffer,
':');
124 ep = strchr(cp,
'\r');
126 ep = strchr(cp,
'\n');
key(const char *keyid, const char *keyhash)
static bool set(const char *id, const char *hash)
static const char * getRealm(void)
static const char * get(const char *id)
static void release(const char *hash)