projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
02b22aa
)
Started implementing global room numbers.
author
Art Cancro
<ajc@citadel.org>
Wed, 18 Nov 1998 03:38:30 +0000
(
03:38
+0000)
committer
Art Cancro
<ajc@citadel.org>
Wed, 18 Nov 1998 03:38:30 +0000
(
03:38
+0000)
citadel/ChangeLog
patch
|
blob
|
history
citadel/citadel.h
patch
|
blob
|
history
citadel/control.c
patch
|
blob
|
history
citadel/control.h
patch
|
blob
|
history
citadel/room_ops.c
patch
|
blob
|
history
citadel/serv_upgrade.c
patch
|
blob
|
history
diff --git
a/citadel/ChangeLog
b/citadel/ChangeLog
index 951b9cce0e14b08a5013966b2290effa3e398857..3e2c02cd3d0382a7c8b276e0e4025869b631dcf1 100644
(file)
--- a/
citadel/ChangeLog
+++ b/
citadel/ChangeLog
@@
-1,3
+1,6
@@
+Tue Nov 17 22:37:48 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Started implementing global room numbers.
+
Sun Nov 15 20:32:34 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* room_ops.c: mailbox rooms always appear on the main floor
* made QR_MAILBOX rooms non-editable
Sun Nov 15 20:32:34 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* room_ops.c: mailbox rooms always appear on the main floor
* made QR_MAILBOX rooms non-editable
diff --git
a/citadel/citadel.h
b/citadel/citadel.h
index e4d82e0a210eca891eec9eaf07d424c04894ccde..f18162ef1849ab9441ec7cae8aa633cb91bebf86 100644
(file)
--- a/
citadel/citadel.h
+++ b/
citadel/citadel.h
@@
-120,6
+120,7
@@
struct CitControl {
long MMhighest; /* highest message number in file */
unsigned MMflags; /* Global system flags */
long MMnextuser; /* highest user number on system */
long MMhighest; /* highest message number in file */
unsigned MMflags; /* Global system flags */
long MMnextuser; /* highest user number on system */
+ long MMnextroom; /* highest room number on system */
};
/* Bits which may appear in CitControl.MMflags. Note that these don't
};
/* Bits which may appear in CitControl.MMflags. Note that these don't
@@
-143,6
+144,7
@@
struct quickroom {
char QRfloor; /* Which floor this room is on */
time_t QRmtime; /* Date/time of last post */
struct ExpirePolicy QRep; /* Message expiration policy */
char QRfloor; /* Which floor this room is on */
time_t QRmtime; /* Date/time of last post */
struct ExpirePolicy QRep; /* Message expiration policy */
+ long QRnumber; /* Globally unique room number */
};
};
diff --git
a/citadel/control.c
b/citadel/control.c
index d6623b99980503d627e678b46c563bedcc80200e..f902bb169f9be782775d31f39cc8bb9cfbb90d70 100644
(file)
--- a/
citadel/control.c
+++ b/
citadel/control.c
@@
-88,6
+88,20
@@
long get_new_user_number(void) {
+/*
+ * get_new_room_number() - Obtain a new, unique ID to be used for a room.
+ */
+long get_new_room_number(void) {
+ begin_critical_section(S_CONTROL);
+ get_control();
+ ++CitControl.MMnextroom;
+ put_control();
+ end_critical_section(S_CONTROL);
+ return(CitControl.MMnextroom);
+ }
+
+
+
/*
* Get or set global configuration options
*/
/*
* Get or set global configuration options
*/
diff --git
a/citadel/control.h
b/citadel/control.h
index 04f73036f861eaaed1ae61f7f7332efe2f6d3860..2c8fee8d6a79f964f46bf560847111e9c34dca45 100644
(file)
--- a/
citadel/control.h
+++ b/
citadel/control.h
@@
-3,4
+3,5
@@
void get_control (void);
void put_control (void);
long int get_new_message_number (void);
long int get_new_user_number (void);
void put_control (void);
long int get_new_message_number (void);
long int get_new_user_number (void);
+long int get_new_room_number (void);
void cmd_conf(char *argbuf);
void cmd_conf(char *argbuf);
diff --git
a/citadel/room_ops.c
b/citadel/room_ops.c
index e0ab0b5aea06782576b5d426c92ce4e405c7303d..7b306ae585b937bd1e851680751079c3f2b76775 100644
(file)
--- a/
citadel/room_ops.c
+++ b/
citadel/room_ops.c
@@
-18,6
+18,7
@@
#include "msgbase.h"
#include "serv_chat.h"
#include "citserver.h"
#include "msgbase.h"
#include "serv_chat.h"
#include "citserver.h"
+#include "control.h"
/*
* Generic routine for determining user access to rooms
/*
* Generic routine for determining user access to rooms
@@
-278,32
+279,19
@@
void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom)) {
-/*
- * Create a database key for storage of message lists
- */
-void msglist_key(char *dbkey, struct quickroom *whichroom) {
- int a;
-
- sprintf(dbkey, "%s%ld", whichroom->QRname, whichroom->QRgen);
- for (a=0; a<strlen(dbkey); ++a) dbkey[a]=tolower(dbkey[a]);
- }
-
/*
* get_msglist() - retrieve room message pointers
*/
void get_msglist(struct quickroom *whichroom) {
struct cdbdata *cdbfr;
/*
* get_msglist() - retrieve room message pointers
*/
void get_msglist(struct quickroom *whichroom) {
struct cdbdata *cdbfr;
- char dbkey[256];
- msglist_key(dbkey, whichroom);
-
if (CC->msglist != NULL) {
free(CC->msglist);
}
CC->msglist = NULL;
CC->num_msgs = 0;
if (CC->msglist != NULL) {
free(CC->msglist);
}
CC->msglist = NULL;
CC->num_msgs = 0;
- cdbfr = cdb_fetch(CDB_MSGLISTS,
dbkey, strlen(dbkey
));
+ cdbfr = cdb_fetch(CDB_MSGLISTS,
&whichroom->QRnumber, sizeof(long
));
if (cdbfr == NULL) {
return;
}
if (cdbfr == NULL) {
return;
}
@@
-319,10
+307,8
@@
void get_msglist(struct quickroom *whichroom) {
* put_msglist() - retrieve room message pointers
*/
void put_msglist(struct quickroom *whichroom) {
* put_msglist() - retrieve room message pointers
*/
void put_msglist(struct quickroom *whichroom) {
- char dbkey[256];
- msglist_key(dbkey, whichroom);
- cdb_store(CDB_MSGLISTS, dbkey, strlen(dbkey),
+ cdb_store(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long),
CC->msglist, CC->num_msgs * sizeof(long));
}
CC->msglist, CC->num_msgs * sizeof(long));
}
@@
-335,10
+321,8
@@
void put_msglist(struct quickroom *whichroom) {
* like "gdbm: illegal data" (no big deal, but could use fixing).
*/
void delete_msglist(struct quickroom *whichroom) {
* like "gdbm: illegal data" (no big deal, but could use fixing).
*/
void delete_msglist(struct quickroom *whichroom) {
- char dbkey[256];
- msglist_key(dbkey, whichroom);
- cdb_delete(CDB_MSGLISTS, dbkey, strlen(dbkey));
+ cdb_delete(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
}
}
@@
-349,13
+333,11
@@
void delete_msglist(struct quickroom *whichroom) {
* may not be the current room (as is the case with cmd_move() for example).
*/
void AddMessageToRoom(struct quickroom *whichroom, long newmsgid) {
* may not be the current room (as is the case with cmd_move() for example).
*/
void AddMessageToRoom(struct quickroom *whichroom, long newmsgid) {
- char dbkey[256];
struct cdbdata *cdbfr;
int num_msgs;
long *msglist;
struct cdbdata *cdbfr;
int num_msgs;
long *msglist;
- msglist_key(dbkey, whichroom);
- cdbfr = cdb_fetch(CDB_MSGLISTS, dbkey, strlen(dbkey));
+ cdbfr = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
if (cdbfr == NULL) {
msglist = NULL;
num_msgs = 0;
if (cdbfr == NULL) {
msglist = NULL;
num_msgs = 0;
@@
-379,7
+361,7
@@
void AddMessageToRoom(struct quickroom *whichroom, long newmsgid) {
msglist[num_msgs - 1] = newmsgid;
/* Write it back to disk. */
msglist[num_msgs - 1] = newmsgid;
/* Write it back to disk. */
- cdb_store(CDB_MSGLISTS,
dbkey, strlen(dbkey
),
+ cdb_store(CDB_MSGLISTS,
&whichroom->QRnumber, sizeof(long
),
msglist, num_msgs * sizeof(long));
/* And finally, free up the memory we used. */
msglist, num_msgs * sizeof(long));
/* And finally, free up the memory we used. */
@@
-1260,6
+1242,7
@@
unsigned create_room(char *new_room_name,
strncpy(qrbuf.QRname,new_room_name,ROOMNAMELEN);
strncpy(qrbuf.QRpasswd,new_room_pass,9);
qrbuf.QRflags = QR_INUSE;
strncpy(qrbuf.QRname,new_room_name,ROOMNAMELEN);
strncpy(qrbuf.QRpasswd,new_room_pass,9);
qrbuf.QRflags = QR_INUSE;
+ qrbuf.QRnumber = get_new_room_number();
if (new_room_type > 0) qrbuf.QRflags=(qrbuf.QRflags|QR_PRIVATE);
if (new_room_type == 1) qrbuf.QRflags=(qrbuf.QRflags|QR_GUESSNAME);
if (new_room_type == 2) qrbuf.QRflags=(qrbuf.QRflags|QR_PASSWORDED);
if (new_room_type > 0) qrbuf.QRflags=(qrbuf.QRflags|QR_PRIVATE);
if (new_room_type == 1) qrbuf.QRflags=(qrbuf.QRflags|QR_GUESSNAME);
if (new_room_type == 2) qrbuf.QRflags=(qrbuf.QRflags|QR_PASSWORDED);
diff --git
a/citadel/serv_upgrade.c
b/citadel/serv_upgrade.c
index c5a5af0803a1cc98a7284aec3f0b64084f5a224f..c8c395b95ac9090bff6af19b67f799fb2b9ec027 100644
(file)
--- a/
citadel/serv_upgrade.c
+++ b/
citadel/serv_upgrade.c
@@
-341,6
+341,8
@@
void imp_globals(void) {
CitControl.MMhighest = atol(value);
if (!strcasecmp(key, "mmnextuser"))
CitControl.MMnextuser = atol(value);
CitControl.MMhighest = atol(value);
if (!strcasecmp(key, "mmnextuser"))
CitControl.MMnextuser = atol(value);
+ if (!strcasecmp(key, "mmnextroom"))
+ CitControl.MMnextroom = atol(value);
}
put_control();
}
put_control();
@@
-693,6
+695,7
@@
void do_export(char *argbuf) {
fprintf(exfp, "globals%c", 0);
fprintf(exfp, "mmhighest%c%ld%c", 0, CitControl.MMhighest, 0);
fprintf(exfp, "mmnextuser%c%ld%c", 0, CitControl.MMnextuser, 0);
fprintf(exfp, "globals%c", 0);
fprintf(exfp, "mmhighest%c%ld%c", 0, CitControl.MMhighest, 0);
fprintf(exfp, "mmnextuser%c%ld%c", 0, CitControl.MMnextuser, 0);
+ fprintf(exfp, "mmnextroom%c%ld%c", 0, CitControl.MMnextroom, 0);
fprintf(exfp, "mmflags%c%d%c", 0, CitControl.MMflags, 0);
fprintf(exfp, "endsection%c", 0);
fprintf(exfp, "mmflags%c%d%c", 0, CitControl.MMflags, 0);
fprintf(exfp, "endsection%c", 0);