]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/user_ops.c
cdb_next_item() now returns both key and value
[citadel.git] / citadel / server / user_ops.c
index d05d0ef3dad8e544330894ceb17ee0a6ad4dd469..7c85b011893b76daa02311e668d234e05de4d9c7 100644 (file)
@@ -391,16 +391,15 @@ void rebuild_usersbynumber(void) {
 //                     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.ptr!=NULL) {
-               usptr = (struct ctdluser *) cdbus.ptr;
+       while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) {
+               usptr = (struct ctdluser *) cdbus.val.ptr;
 
                if (usptr->uid == number) {
                        syslog(LOG_DEBUG, "user_ops: found uid=%d username=%s", usptr->uid, usptr->fullname);
@@ -1031,7 +1030,7 @@ int CtdlForgetThisRoom(void) {
 // 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);
@@ -1044,8 +1043,8 @@ void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) {
        cdb_rewind(CDB_USERS);
 
        // Phase 1 : build an array of all our user account names
-       while (cdbus = cdb_next_item(CDB_USERS), cdbus.ptr!=NULL) {
-               usptr = (struct ctdluser *) cdbus.ptr;
+       while (cdbus = cdb_next_item(CDB_USERS), cdbus.val.ptr!=NULL) {
+               usptr = (struct ctdluser *) cdbus.val.ptr;
                if (strlen(usptr->fullname) > 0) {
                        array_append(all_users, usptr->fullname);
                }