$Log$
+ Revision 607.14 2003/06/29 04:13:32 ajc
+ * Renamed:
+ S_QUICKROOM to S_ROOMS
+ S_USERSUPP to S_USERS
+ CDB_QUICKROOM to CDB_ROOMS
+ CDB_USERSUPP to CDB_USERS
+
Revision 607.13 2003/06/29 04:07:11 ajc
* Globally renamed "struct quickroom" and "struct usersupp" to
"struct room" and "struct user".
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
* was in, the reference count will reach zero and the message will
* automatically be deleted from the database. We do this in a
* separate pass because there might be plug-in hooks getting called,
- * and we don't want that happening during an S_QUICKROOM critical
+ * and we don't want that happening during an S_ROOMS critical
* section.
*/
if (num_deleted) for (i=0; i<num_deleted; ++i) {
memset(qrbuf, 0, sizeof(struct room));
/* First, try the public namespace */
- cdbqr = cdb_fetch(CDB_QUICKROOM,
+ cdbqr = cdb_fetch(CDB_ROOMS,
lowercase_name, strlen(lowercase_name));
/* If that didn't work, try the user's personal namespace */
snprintf(personal_lowercase_name,
sizeof personal_lowercase_name, "%010ld.%s",
CC->user.usernum, lowercase_name);
- cdbqr = cdb_fetch(CDB_QUICKROOM,
+ cdbqr = cdb_fetch(CDB_ROOMS,
personal_lowercase_name,
strlen(personal_lowercase_name));
}
{
register int retval;
retval = getroom(qrbuf, room_name);
- if (retval == 0) begin_critical_section(S_QUICKROOM);
+ if (retval == 0) begin_critical_section(S_ROOMS);
return(retval);
}
}
if (qrbuf == NULL) {
- cdb_delete(CDB_QUICKROOM,
+ cdb_delete(CDB_ROOMS,
lowercase_name, strlen(lowercase_name));
} else {
time(&qrbuf->QRmtime);
- cdb_store(CDB_QUICKROOM,
+ cdb_store(CDB_ROOMS,
lowercase_name, strlen(lowercase_name),
qrbuf, sizeof(struct room));
}
{
putroom(qrbuf);
- end_critical_section(S_QUICKROOM);
+ end_critical_section(S_ROOMS);
}
struct room qrbuf;
struct cdbdata *cdbqr;
- cdb_rewind(CDB_QUICKROOM);
+ cdb_rewind(CDB_ROOMS);
- while (cdbqr = cdb_next_item(CDB_QUICKROOM), cdbqr != NULL) {
+ while (cdbqr = cdb_next_item(CDB_ROOMS), cdbqr != NULL) {
memset(&qrbuf, 0, sizeof(struct room));
memcpy(&qrbuf, cdbqr->ptr,
((cdbqr->len > sizeof(struct room)) ?
/* Take care of all the formalities. */
- begin_critical_section(S_USERSUPP);
+ begin_critical_section(S_USERS);
CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
/* Know the room ... but not if it's the page log room, or if the
vbuf.v_flags = vbuf.v_flags | V_ACCESS;
}
CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
- end_critical_section(S_USERSUPP);
+ end_critical_section(S_USERS);
/* Check for new mail */
newmailcount = NewMailCount();
}
cprintf("%d Who knows room:\n", LISTING_FOLLOWS);
- cdb_rewind(CDB_USERSUPP);
- while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
+ cdb_rewind(CDB_USERS);
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
memset(&temp, 0, sizeof temp);
memcpy(&temp, cdbus->ptr, sizeof temp);
cdb_free(cdbus);
}
}
- begin_critical_section(S_QUICKROOM);
+ begin_critical_section(S_ROOMS);
if ( (getroom(&qrtmp, new_name) == 0)
&& (strcasecmp(new_name, old_name)) ) {
ret = crr_ok;
}
- end_critical_section(S_QUICKROOM);
+ end_critical_section(S_ROOMS);
/* Adjust the floor reference counts if necessary */
if (new_floor != old_floor) {
unlink(filename);
/* Delete the messages in the room
- * (Careful: this opens an S_QUICKROOM critical section!)
+ * (Careful: this opens an S_ROOMS critical section!)
*/
CtdlDeleteMessages(qrbuf->QRname, 0L, "");
strcpy(tempfilename, tmpnam(NULL));
/* First, back out all old version records to a flat file */
- cdb_rewind(CDB_USERSUPP);
- while(cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
+ cdb_rewind(CDB_USERS);
+ while(cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct pre555user));
memcpy(&usbuf, cdbus->ptr,
( (cdbus->len > sizeof(struct pre555user)) ?
* Various things we need to lock and unlock
*/
enum {
- S_USERSUPP,
- S_QUICKROOM,
+ S_USERS,
+ S_ROOMS,
S_SESSION_TABLE,
S_FLOORTAB,
S_CHATQUEUE,
*/
enum {
CDB_MSGMAIN, /* message base */
- CDB_USERSUPP, /* user file */
- CDB_QUICKROOM, /* room index */
+ CDB_USERS, /* user file */
+ CDB_ROOMS, /* room index */
CDB_FLOORTAB, /* floor index */
CDB_MSGLISTS, /* room message lists */
CDB_VISIT, /* user/room relationships */
USER RELATED FUNCTIONS
----------------------
- The fundamental user data is stored in "struct usersupp" which is defined
+ The fundamental user data is stored in "struct user" which is defined
in citadel.h. The following functions are available:
- int getuser(struct usersupp *usbuf, char name[])
+ int getuser(struct user *usbuf, char name[])
- Given the name of a requested user and a buffer to store the usersupp
+ Given the name of a requested user and a buffer to store the user
record in, getuser() will search the userlog for the named user and load its
data into the buffer. getuser() returns 0 upon success or a nonzero error
code if the requested operation could not be performed.
- void putuser(struct usersupp *usbuf, char *name)
+ void putuser(struct user *usbuf, char *name)
After reading in a user record with getuser() and perhaps modifying the data
in some way, a program may use putuser() to write it back to disk.
- int lgetuser(struct usersupp *usbuf, char *name)
- void lputuser(struct usersupp *usbuf, char *name)
+ int lgetuser(struct user *usbuf, char *name)
+ void lputuser(struct user *usbuf, char *name)
If critical-section operation is required, this pair of calls may be used.
They function the same as getuser() and putuser(), except that lgetuser()
entire server.
- void ForEachUser(void (*CallBack)(struct usersupp *EachUser))
+ void ForEachUser(void (*CallBack)(struct user *EachUser))
This allows a user-supplied function to be called once for each user on
the system. The user-supplied function will be called with a pointer to a
-usersupp structure as its only argument.
+user structure as its only argument.
- int getuserbynumber(struct usersupp *usbuf, long int number)
+ int getuserbynumber(struct user *usbuf, long int number)
getuserbynumber() functions similarly to getuser(), except that it is
supplied with a user number rather than a name. Calling this function
FUNCTIONS WHICH MANIPULATE USER/ROOM RELATIONSHIPS
void CtdlGetRelationship(struct visit *vbuf,
- struct usersupp *rel_user,
- struct quickroom *rel_room);
+ struct user *rel_user,
+ struct room *rel_room);
void CtdlSetRelationship(struct visit *newvisit,
- struct usersupp *rel_user,
- struct quickroom *rel_room);
+ struct user *rel_user,
+ struct room *rel_room);
These functions get/set a "struct visit" structure which may contain
information about the relationship between a user and a room. Specifically:
- int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *userbuf)
+ int CtdlRoomAccess(struct room *roombuf, struct user *userbuf)
This is a convenience function which uses CtdlGetRelationship() to determine
whether a user has access to a room. It returns a bucket of bits which may
actually creating it by setting really_create to 0.
create_room() returns the flags associated with the new room (as in the
-data structure item quickroom.QRflags). If the room cannot be created (for
+data structure item room.QRflags). If the room cannot be created (for
example, a room with the name already exists), it returns 0.
by Citadel. Here are some of the tables we keep on disk:
- USERSUPP
- --------
+ USER RECORDS
+ ------------
- This table contains all user records. It's called 'usersupp' because it was
-once a supplementary file (at one point in ancient history, we created a user
-record on the underlying operating system for each user). It's indexed by
+ This table contains all user records. It's indexed by
user name (translated to lower case for indexing purposes). The records in
this file look something like this:
-struct usersupp { /* User record */
+struct user { /* User record */
int version; /* Cit vers. which created this rec */
uid_t uid; /* Associate with a unix account? */
char password[32]; /* password (for BBS-only users) */
information so we set it up dynamically.
- QUICKROOM
- ---------
+ ROOM RECORDS
+ ------------
- These are room records. One per room. It's called 'quickroom' because at
-one time it was a quick index hash type of thing (there was a pair called
-quickroom and fullroom). There is a quickroom record for every room on the
+ These are room records. There is a room record for every room on the
system, public or private or mailbox. It's indexed by room name (also in
lower case for easy indexing) and it contains records which look like this:
-struct quickroom {
+struct room {
char QRname[ROOMNAMELEN]; /* Name of room */
char QRpasswd[10]; /* Only valid if it's a private rm */
long QRroomaide; /* User number of room aide */
to prevent duplicates from being posted if someone misconfigures the network
and a loop is created. This table goes unused on a non-networked Citadel.
- MSGMAIN
- -------
+ THE MESSAGE STORE
+ -----------------
This is where all message text is stored. It's indexed by message number:
give it a number, get back a message. Messages are numbered sequentially, and
This has changed a couple of times over the course of Citadel's history. At
this point it's very simple, again due to the fact that record managers are
-used for everything. The user file (usersupp) is indexed using the user's
+used for everything. The user file (user) is indexed using the user's
name, converted to all lower-case. Searching for a user, then, is easy. We
just lowercase the name we're looking for and query the database. If no
match is found, it is assumed that the user does not exist.
basis by storing it in the 'visit' record for a particular room/user
combination. It is visit.v_view and is an integer. Naturally, there also
needs to be a default, for users who have never visited the room before. This
-is in the room record as quickroom.QRdefaultview (and is also an integer).
+is in the room record as room.QRdefaultview (and is also an integer).
The values currently defined are:
}
lowercase_name[sizeof(lowercase_name) - 1] = 0;
- cdbus = cdb_fetch(CDB_USERSUPP, lowercase_name, strlen(lowercase_name));
+ cdbus = cdb_fetch(CDB_USERS, lowercase_name, strlen(lowercase_name));
if (cdbus == NULL) { /* user not found */
return(1);
}
retcode = getuser(usbuf, name);
if (retcode == 0) {
- begin_critical_section(S_USERSUPP);
+ begin_critical_section(S_USERS);
}
return (retcode);
}
lowercase_name[sizeof(lowercase_name) - 1] = 0;
usbuf->version = REV_LEVEL;
- cdb_store(CDB_USERSUPP,
+ cdb_store(CDB_USERS,
lowercase_name, strlen(lowercase_name),
usbuf, sizeof(struct user));
void lputuser(struct user *usbuf)
{
putuser(usbuf);
- end_critical_section(S_USERSUPP);
+ end_critical_section(S_USERS);
}
/*
{
struct cdbdata *cdbus;
- cdb_rewind(CDB_USERSUPP);
+ cdb_rewind(CDB_USERS);
- while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
memset(usbuf, 0, sizeof(struct user));
memcpy(usbuf, cdbus->ptr,
((cdbus->len > sizeof(struct user)) ?
sizeof(struct user) : cdbus->len));
cdb_free(cdbus);
if (usbuf->usernum == number) {
- cdb_close_cursor(CDB_USERSUPP);
+ cdb_close_cursor(CDB_USERS);
return (0);
}
}
cdb_delete(CDB_VISIT, &usbuf.usernum, sizeof(long));
/* delete the userlog entry */
- cdb_delete(CDB_USERSUPP, lowercase_name, strlen(lowercase_name));
+ cdb_delete(CDB_USERS, lowercase_name, strlen(lowercase_name));
/* remove the user's bio file */
snprintf(filename, sizeof filename, "./bio/%ld", usbuf.usernum);
/* There are unvalidated users. Traverse the user database,
* and return the first user we find that needs validation.
*/
- cdb_rewind(CDB_USERSUPP);
- while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
+ cdb_rewind(CDB_USERS);
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct user));
memcpy(&usbuf, cdbus->ptr,
((cdbus->len > sizeof(struct user)) ?
if ((usbuf.flags & US_NEEDVALID)
&& (usbuf.axlevel > 0)) {
cprintf("%d %s\n", MORE_DATA, usbuf.fullname);
- cdb_close_cursor(CDB_USERSUPP);
+ cdb_close_cursor(CDB_USERS);
return;
}
}
struct user usbuf;
struct cdbdata *cdbus;
- cdb_rewind(CDB_USERSUPP);
+ cdb_rewind(CDB_USERS);
- while (cdbus = cdb_next_item(CDB_USERSUPP), cdbus != NULL) {
+ while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
memset(&usbuf, 0, sizeof(struct user));
memcpy(&usbuf, cdbus->ptr,
((cdbus->len > sizeof(struct user)) ?