$Log$
+ Revision 580.15 2001/07/29 22:24:04 nbryant
+ - added a new function to the database interface, cdb_close_cursor(). always
+ call this when you're finished with a traversal but didn't bother reading all
+ the way to the end.
+
+ - removed several cdb_begin_transaction()/cdb_end_transaction() calls that are
+ no longer needed because of the read-only cursor support.
+
Revision 580.14 2001/07/29 20:56:09 nbryant
change ForEachRoom to use read-only cursors by default. it can be overridden to
still use read/write cursors by doing:
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
phree(cdb);
}
+void cdb_close_cursor(cdb)
+{
+ while (max_keys <= CC->cs_pid) {
+ ++max_keys;
+ if (dtkey == NULL) {
+ dtkey = (datum *)
+ mallok((sizeof(datum) * max_keys));
+ } else {
+ dtkey = (datum *)
+ reallok(dtkey, (sizeof(datum) * max_keys));
+ }
+ dtkey[max_keys - 1].dsize = 0;
+ dtkey[max_keys - 1].dptr = NULL;
+ }
+
+ if (dtkey[CC->cs_pid].dptr != NULL) {
+ phree(dtkey[CC->cs_pid].dptr);
+ }
+ dtkey[CC->cs_pid].dptr = NULL;
+ dtkey[CC->cs_pid].dsize = 0;
+}
+
/*
* Prepare for a sequential search of an entire database. (In the gdbm model,
void cdb_free (struct cdbdata *cdb);
void cdb_rewind (int cdb);
struct cdbdata *cdb_next_item (int cdb);
+void cdb_close_cursor(int cdb);
void cdb_begin_transaction(void);
void cdb_end_transaction(void);
void cdb_allocate_tsd(void);
phree(cdb);
}
+void cdb_close_cursor(int cdb)
+{
+ if (MYCURSORS[cdb] != NULL)
+ cclose(MYCURSORS[cdb]);
+
+ MYCURSORS[cdb] = NULL;
+}
/*
* Prepare for a sequential search of an entire database.
struct usersupp temp;
struct cdbdata *cdbus;
- cdb_begin_transaction();
getuser(&CC->usersupp, CC->curr_user);
if (CtdlAccessCheck(ac_room_aide)) return;
)
cprintf("%s\n", temp.fullname);
}
- cdb_end_transaction();
cprintf("000\n");
}
*/
if (!really_create) return (qrbuf.QRflags);
- /* cdb_begin_transaction(); commented out because a transaction
- is already open when creating __CtdlSMTPspoolout__ while
- initializing serv_smtp.c
- */
-
qrbuf.QRnumber = get_new_room_number();
qrbuf.QRhighest = 0L; /* No messages in this room yet */
time(&qrbuf.QRgen); /* Use a timestamp as the generation number */
lputuser(&CC->usersupp);
/* resume our happy day */
- /* cdb_end_transaction(); */
return (qrbuf.QRflags);
}
ForEachUser(AddValidUser, NULL);
/* Now traverse through the visits, purging irrelevant records... */
- cdb_begin_transaction();
cdb_rewind(CDB_VISIT);
while(cdbvisit = cdb_next_item(CDB_VISIT), cdbvisit != NULL) {
memset(&vbuf, 0, sizeof(struct visit));
}
- cdb_end_transaction();
-
/* Free the valid room/gen combination list */
while (ValidRoomList != NULL) {
vrptr = ValidRoomList->next;
strcpy(tempfilename, tmpnam(NULL));
/* First, back out all old version records to a flat file */
- cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while(cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct pre555usersupp));
cdb_free(cdbus);
fwrite(&usbuf, sizeof(struct pre555usersupp), 1, fp);
}
- cdb_end_transaction();
/* ...and overwrite the records with new format records */
rewind(fp);
struct visit vbuf;
struct cdbdata *cdbv;
- cdb_begin_transaction();
cdb_rewind(CDB_VISIT);
while (cdbv = cdb_next_item(CDB_VISIT), cdbv != NULL) {
cprintf("%u\n", vbuf.v_flags);
}
- cdb_end_transaction();
}
{
struct cdbdata *cdbus;
- cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
sizeof(struct usersupp) : cdbus->len));
cdb_free(cdbus);
if (usbuf->usernum == number) {
- cdb_end_transaction();
+ cdb_close_cursor(CDB_USERSUPP);
return (0);
}
}
- cdb_end_transaction();
return (-1);
}
/* There are unvalidated users. Traverse the usersupp database,
* and return the first user we find that needs validation.
*/
- cdb_begin_transaction();
cdb_rewind(CDB_USERSUPP);
while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct usersupp));
if ((usbuf.flags & US_NEEDVALID)
&& (usbuf.axlevel > 0)) {
cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
- cdb_end_transaction();
+ cdb_close_cursor(CDB_USERSUPP);
return;
}
}
- cdb_end_transaction();
/* If we get to this point, there are no more unvalidated users.
* Therefore we clear the "users need validation" flag.