*/
+
/*
* Attach an OpenID to a Citadel account
*/
*/
void openid_purge(struct ctdluser *usbuf) {
struct cdbdata *cdboi;
+ HashList *keys = NULL;
+ HashPos *HashPos;
+ char *deleteme = NULL;
+ long len;
+ void *Value;
+ char *Key;
+
+ keys = NewHash(1, NULL);
+ if (!keys) return;
+
cdb_rewind(CDB_OPENID);
while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
if (cdboi->len > sizeof(long)) {
if (((long)*(cdboi->ptr)) == usbuf->usernum) {
- CtdlLogPrintf(CTDL_DEBUG, "FIXME we have to delete an openid\n");
+ deleteme = strdup(cdboi->ptr + sizeof(long)),
+ Put(keys, deleteme, strlen(deleteme), deleteme, generic_free_handler);
}
}
cdb_free(cdboi);
}
- /* FIXME finish this */
+ /* Go through the hash list, deleting keys we stored in it */
+
+ HashPos = GetNewHashPos();
+ while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
+ {
+ CtdlLogPrintf(CTDL_DEBUG, "Deleting associated OpenID <%s>\n", Value);
+ cdb_delete(CDB_OPENID, Value, strlen(Value));
+ /* note: don't free(Value) -- deleting the hash list will handle this for us */
+ }
+ DeleteHashPos(&HashPos);
+ DeleteHash(&keys);
}
-/*
- * Callback function to free a pointer (used below in the hash list)
- */
-void free_oid_key(void *ptr) {
- free(ptr);
-}
/*
char thiskey[1024];
char thisdata[1024];
HashList *keys = NULL;
- HashPos *HashPos;
struct ctdl_openid *oiddata = (struct ctdl_openid *) CC->openid_data;
keys = NewHash(1, NULL);
extract_token(thiskey, buf, 0, '|', sizeof thiskey);
extract_token(thisdata, buf, 1, '|', sizeof thisdata);
CtdlLogPrintf(CTDL_DEBUG, "%s: [%d] %s\n", thiskey, strlen(thisdata), thisdata);
- Put(keys, thiskey, strlen(thiskey), strdup(thisdata), free_oid_key);
+ Put(keys, thiskey, strlen(thiskey), strdup(thisdata), generic_free_handler);
}
}
cprintf("000\n");
- /* Free the hash list */
+ /*
+ * We will eventually do something with the data in the hash list.
+ *
long len;
void *Value;
char *Key;
-
+ HashPos *HashPos;
HashPos = GetNewHashPos();
while (GetNextHashPos(keys, HashPos, &len, &Key, &Value)!=0)
{
- free(Value);
}
DeleteHashPos(&HashPos);
+ */
+
+ DeleteHash(&keys); /* This will free() all the key data for us */
}