17 #include <sipwitch-config.h>
18 #include <ucommon/ucommon.h>
19 #include <ucommon/export.h>
24 #define USER_KEY_SIZE 177
28 static mempager cache_heap(16384);
30 static condlock_t user_lock;
54 after = (
Cache *)node->Next;
60 node->enlist(freelist);
70 memset(&user_keys, 0,
sizeof(user_keys));
77 expire(&user_keys[i], &user_freelist);
89 shell::log(shell::ERR,
"%s\n",
90 _TEXT(
"usercache; cannot access file"));
97 linked_pointer<UserCache> up = user_keys[i];
99 if(!up->expires || up->expires > now) {
100 Socket::query((
struct sockaddr *)(&up->address), buffer,
sizeof(buffer));
102 fprintf(fp,
"%s=%s; expires=%ld\n",
103 up->userid, buffer, (
long)(up->expires - now));
105 fprintf(fp,
"%s=%s\n", up->userid, buffer);
117 assert(
id != NULL && *
id != 0);
119 linked_pointer<UserCache> up;
121 up = user_keys[path];
123 if(eq(up->userid,
id))
150 LinkedObject::release();
159 void UserCache::add(
const char *
id,
struct sockaddr *addr, time_t create,
unsigned expire)
161 assert(
id != NULL && *
id != 0);
179 user_freelist = cp->Next;
182 void *mp = cache_heap.alloc(
sizeof(
UserCache));
186 cp->enlist(&user_keys[path]);
static UserCache * request(const char *id)
static void userdump(void)
static void expire(LinkedObject **list, LinkedObject **free)
static void cleanup(void)
static UserCache * find(const char *id)
Find user record.
URI cache for tags, local, and remote id's.
static bool static FILE * output(const char *id)
Used to open an output session for returning control data.
Manage control interface.
static void add(const char *id, struct sockaddr *addr, time_t create, unsigned expire=130)
Add or refresh user in cache.
User caches may be used to contact nearby users in multicast registries.
void set(struct sockaddr *addr)