Added id handler

This commit is contained in:
James Booth
2015-05-16 21:55:51 +01:00
parent 50cd28a977
commit ede3ccab9d
10 changed files with 88 additions and 11 deletions

View File

@@ -1,6 +1,10 @@
#include <stdlib.h>
#include <glib.h>
#include <string.h>
static char *required_passwd = NULL;
static GHashTable *idstubs;
void
prime_required_passwd(char *password)
@@ -13,3 +17,23 @@ prime_get_passwd(void)
{
return required_passwd;
}
void
prime_for(char *id, char *stanza)
{
if (!idstubs) {
idstubs = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
}
g_hash_table_insert(idstubs, strdup(id), strdup(stanza));
}
char*
prime_get_for(const char *id)
{
if (idstubs) {
return g_hash_table_lookup(idstubs, id);
}
return NULL;
}