]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/user_ops.c
validate_recipients() - completed removal of unused param
[citadel.git] / citadel / server / user_ops.c
index 76325e984cc3f8f56997cfddd5d42913a8f92462..e35b00a27e71b222b20c5f3772b9b7aaac255552 100644 (file)
@@ -55,7 +55,7 @@ int CtdlGetUser(struct ctdluser *usbuf, char *name) {
        }
        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) {
@@ -188,7 +188,7 @@ void reindex_user_928(char *username, void *out_data) {
 
        // 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;
        }
@@ -245,8 +245,8 @@ void CtdlGetRelationship(struct visit *vbuf, struct ctdluser *rel_user, struct c
        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.
@@ -358,7 +358,7 @@ int CtdlGetUserByNumber(struct ctdluser *usbuf, long number) {
        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);
        }
@@ -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.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);
@@ -506,7 +505,7 @@ int CtdlLoginExistingUser(const char *trythisname) {
        
                // 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);
@@ -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);
@@ -1041,11 +1040,10 @@ 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.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);
                }