}
cdbus = cdb_fetch(CDB_USERS, usernamekey, strlen(usernamekey));
- if (cdbus.len == 0) { // user not found
+ if (cdbus.ptr == NULL) { // user not found
return(1);
}
if (usbuf != NULL) {
// Fetch the user record using the old index format
cdbus = cdb_fetch(CDB_USERS, oldkey, strlen(oldkey));
- if (cdbus.len == 0) {
+ if (cdbus.ptr == NULL) {
syslog(LOG_INFO, "user_ops: <%s> not found, were they already reindexed?", username);
return;
}
vbuf->v_usernum = rel_user->usernum;
cdbvisit = cdb_fetch(CDB_VISIT, vbuf, (sizeof(long)*3));
- if (cdbvisit.len > 0) {
- memcpy(vbuf, cdbvisit.ptr, ((cdbvisit.len > sizeof(struct visit)) ? sizeof(struct visit) : cdbvisit.len));
+ if (cdbvisit.ptr != NULL) {
+ memcpy(vbuf, cdbvisit.ptr, ((cdbvisit.len > sizeof(struct visit)) ? sizeof(struct visit) : cdbvisit.len));
}
else {
// If this is the first time the user has seen this room, set the view to be the default for the room.
int r;
cdbun = cdb_fetch(CDB_USERSBYNUMBER, &number, sizeof(long));
- if (cdbun.len == 0) {
+ if (cdbun.ptr == NULL) {
syslog(LOG_INFO, "user_ops: %ld not found", number);
return(-1);
}
// Returns 0 if user was found
int getuserbyuid(struct ctdluser *usbuf, uid_t number) {
- struct cdbdata cdbus;
+ struct cdbkeyval cdbus;
struct ctdluser *usptr;
int return_value = (-1);
- // Yes, we do this the long way.
+ // Yes, we do this the long way. Someday we might want to try an index.
// No, we don't use CtdlForEachUser() because that requires multiple reads for each record
- // TODO: make an index
cdb_rewind(CDB_USERS);
- while (cdbus = cdb_next_item(CDB_USERS), cdbus.len>0) {
- usptr = (struct ctdluser *) cdbus.ptr;
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) { // always read through to the end
+ usptr = (struct ctdluser *) cdbus.val.ptr;
if (usptr->uid == number) {
syslog(LOG_DEBUG, "user_ops: found uid=%d username=%s", usptr->uid, usptr->fullname);
// If that didn't work, try to log in as if the supplied name * is an e-mail address
if (found_user != 0) {
- valid = validate_recipients(username, NULL, 0);
+ valid = validate_recipients(username, 0);
if (valid != NULL) {
if (valid->num_local == 1) {
found_user = CtdlGetUser(&CC->user, valid->recp_local);
// Traverse the user file and perform a callback for each user record.
// (New improved version that runs in two phases so that callbacks can perform writes without having a r/o cursor open)
void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) {
- struct cdbdata cdbus;
+ struct cdbkeyval cdbus;
struct ctdluser *usptr;
Array *all_users = array_new(USERNAME_SIZE);
}
- cdb_rewind(CDB_USERS);
-
// Phase 1 : build an array of all our user account names
- while (cdbus = cdb_next_item(CDB_USERS), cdbus.len > 0) {
- usptr = (struct ctdluser *) cdbus.ptr;
+ cdb_rewind(CDB_USERS);
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) { // always read through to the end
+ usptr = (struct ctdluser *) cdbus.val.ptr;
if (strlen(usptr->fullname) > 0) {
array_append(all_users, usptr->fullname);
}