// 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);
// 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.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);
}