+Sun Oct 4 23:35:18 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Did the big migration to the new data structures. Lots of stuff is
+ now broken. Basic moving from room to room works, but Mail is
+ broken, and some of the administrative commands are unimplemented.
+
1998-10-02 Nathan Bryant <bryant@cs.usm.maine.edu>
* configure.in: autologin now defaults to disabled
int screenheight;
unsigned room_flags;
char room_name[32];
-char ugname[20];
+char ugname[ROOMNAMELEN];
long uglsn; /* holds <u>ngoto info */
char is_mail = 0; /* nonzero when we're in a mail room */
char axlevel = 0; /* access level */
*/
typedef unsigned char CIT_UBYTE;
+#define ROOMNAMELEN 128
+
struct config {
char c_nodename[16]; /* UUCP and Citadel nodename */
char c_fqdn[64]; /* Fully Qualified Domain Name */
char c_initax; /* initial access level */
char c_regiscall; /* call number to register on */
char c_twitdetect; /* twit detect flag */
- char c_twitroom[20]; /* twit detect msg move to room */
+ char c_twitroom[ROOMNAMELEN]; /* twit detect msg move to room */
int c_defent; /* command generated by <E> key */
char c_moreprompt[80]; /* paginator prompt */
char c_restrict; /* restrict Internet mail flag */
/* Defines the relationship of a user to a particular room */
struct visit {
- char v_roomname[20];
+ char v_roomname[ROOMNAMELEN];
long v_generation;
long v_lastseen;
unsigned int v_flags;
* Room records
*/
struct quickroom {
- char QRname[20]; /* Max. len is 19, plus null term */
+ char QRname[ROOMNAMELEN]; /* Name of room */
char QRpasswd[10]; /* Only valid if it's a private rm */
long QRroomaide; /* User number of room aide */
long QRhighest; /* Highest message NUMBER in room */
#define MT_CITADEL 0 /* Citadel proprietary */
#define MT_RFC822 2 /* RFC822 */
#define MT_RAW 3 /* IGnet raw format */
+
+
+
+#define BASEROOM "Lobby"
+#define MAILROOM "Mail"
+#define AIDEROOM "Aide"
+
lprintf(7, "Checking floor reference counts\n");
check_ref_counts();
+
+ lprintf(7, "Creating base rooms (if necessary)\n");
+ create_room(BASEROOM, 0, "", 0);
+ create_room(AIDEROOM, 4, "", 0);
+ create_room(config.c_twitroom, 0, "", 0);
}
/*
*/
void set_wtmpsupp(char *newtext)
{
- strncpy(CC->cs_room,newtext,19);
- CC->cs_room[19] = 0;
+ strncpy(CC->cs_room,newtext,ROOMNAMELEN-1);
+ CC->cs_room[ROOMNAMELEN-1] = 0;
time(&CC->cs_lastupdt);
/* Run any routines registered by loadable modules */
{
if ((newroomname) && (newroomname[0]))
{
- bzero(CC->fake_roomname, 20);
- strncpy(CC->fake_roomname, newroomname, 19);
+ bzero(CC->fake_roomname, ROOMNAMELEN);
+ strncpy(CC->fake_roomname, newroomname, ROOMNAMELEN-1);
}
else
CC->fake_roomname[0] = '\0';
/*
* Initialize some variables specific to our context.
*/
- CC->curr_rm = (-1);
CC->logged_in = 0;
CC->internal_pgm = 0;
CC->download_fp = NULL;
#include <string.h>
#include <sys/stat.h>
#include <time.h>
+#include <limits.h>
#include <pthread.h>
#include "citadel.h"
#include "server.h"
char newroom[256];
char buf[256];
int a;
- int target_room = (-1);
struct quickroom qrbuf;
extract(filename,cmdbuf,0);
return;
}
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&qrbuf,a);
- if (!strcasecmp(qrbuf.QRname,newroom)) target_room = a;
- }
- if (target_room < 0) {
- cprintf("%d Room '%s' not found.\n",
- ERROR+ROOM_NOT_FOUND,newroom);
+ if (getroom(&qrbuf, newroom)!=0) {
+ cprintf("%d '%s' does not exist.\n",
+ ERROR, newroom);
return;
}
- getroom(&qrbuf, target_room);
if ((qrbuf.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d '%s' is not a directory room.\n",
ERROR+NOT_HERE,qrbuf.QRname);
sprintf(pathname, "./images/floor.%d.gif", which_floor);
}
else if (!strcasecmp(filename, "_roompic_")) {
- sprintf(pathname, "./images/room.%d.gif", CC->curr_rm);
+ assoc_file_name(pathname, &CC->quickroom, "images");
}
else {
for (a=0; a<strlen(filename); ++a) {
}
if ( (!strcasecmp(basenm, "_roompic_")) && (is_room_aide()) ) {
- sprintf(CC->upl_path, "./images/room.%d.gif", CC->curr_rm);
+ assoc_file_name(CC->upl_path, &CC->quickroom, "images");
}
if (strlen(CC->upl_path) == 0) {
#include <ctype.h>
#include <string.h>
#include <errno.h>
+#include <limits.h>
#include <pthread.h>
#include "citadel.h"
#include "server.h"
#define QR_DOWNLOAD 128 /* Allowed to download */
#define QR_VISDIR 256 /* Visible directory */
#define QR_ANONONLY 512 /* Anonymous-Only room */
-#define QR_ANON2 1024 /* Anonymous-Option room */
+#define QR_ANONOPT 1024 /* Anonymous-Option room */
#define QR_NETWORK 2048 /* Shared network room */
#define QR_PREFONLY 4096 /* Preferred status needed to enter */
#define QR_READONLY 8192 /* Aide status required to post */
-
+#define QR_MAILBOX 16384 /* Set if this is a private mailbox */
#define US_NEEDVALID 1 /* User needs to be validated */
#define US_PERM 4 /* Permanent user */
void serv_puts(char *buf);
void serv_gets(char *buf);
-
-struct CtdlServerHandle {
- char ServerAddress[64];
- int ServerPort;
- char ipgmSecret[32];
- char UserName[32];
- char Password[32];
- char InitialRoom[32];
- int AssocClientSession;
- };
-
-struct CtdlRoomInfo {
- char RoomName[32];
- time_t mtime;
- };
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <limits.h>
#include <netdb.h>
#include <string.h>
#include <pthread.h>
}
b=0;
- if (room_flags&QR_ANON2) {
+ if (room_flags&QR_ANONOPT) {
printf("Anonymous (Y/N)? ");
if (yesno()==1) b=1;
}
char prtfile[16];
char pagin;
char cmd[256];
- char targ[20];
+ char targ[ROOMNAMELEN];
signal(SIGINT,SIG_IGN);
signal(SIGQUIT,SIG_IGN);
case 'a': goto RAGAIN;
case 'b': a=a-(rdir*2);
break;
- case 'm': newprompt("Enter target room: ",targ,19);
+ case 'm': newprompt("Enter target room: ",
+ targ,ROOMNAMELEN-1);
if (strlen(targ)>0) {
sprintf(cmd,"MOVE %ld|%s",
msg_arr[a],targ);
#define MSGS_GT 5
extern struct config config;
-int twitroom=-1;
/*
cprintf("%d not logged in\n",ERROR+NOT_LOGGED_IN);
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d no room\n",ERROR);
- return;
- }
get_mm();
- get_msglist(CC->curr_rm);
+ get_msglist(&CC->quickroom);
getuser(&CC->usersupp,CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
/* where are we going to get our text from? */
/* nonzero if we should use hypertext mode */
{
- int a,b,c,real,old;
+ int a,b,c;
+ int real = 0;
+ int old = 0;
CIT_UBYTE ch;
char aaa[140];
char buffer[256];
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No room selected.\n",ERROR);
- return;
- }
/* We used to need to check in the current room's message list
* to determine where the message's disk position. We no longer need
-
-
-/* FIX ... rewrite this to simply check for the existence of the twitroom,
- * and create it if necessary. No slot-numbers will need to be loaded.
- * (Actually, twitroom should be created during the same portion of startup
- * that creates Lobby/Mail/Aide.)
- */
-void loadtroom(void) {
- struct quickroom qrbuf;
- int a;
- unsigned newflags;
-
- /* first try to locate the twit room */
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&qrbuf,a);
- if (!strcasecmp(qrbuf.QRname,config.c_twitroom)) {
- twitroom = a;
- return;
- }
- }
-
- /* if not found, try to create it - put it in the last slot */
- twitroom = get_free_room_slot(-1);
- if (twitroom>=0) {
- newflags = create_room(twitroom,config.c_twitroom,0,"",0);
- return;
- }
-
- /* as a last resort, point to Aide> */
- twitroom = 2;
- }
-
-
/*
* this is a simple file copy routine.
*/
int mailtype, /* local or remote type, see citadel.h */
int generate_id) /* set to 1 to generate an 'I' field */
{
- struct usersupp tempUS;
char aaa[100];
- int hold_rm;
- struct cdbdata *cdbmb;
- long *dmailbox;
- int dnum_mails;
+ char hold_rm[ROOMNAMELEN];
long newmsgid;
char *message_in_memory;
struct stat statbuf;
newmsgid = send_message(message_in_memory, templen, generate_id);
free(message_in_memory);
if (newmsgid <= 0L) return;
- hold_rm=(-1);
+
+ strcpy(hold_rm, "");
/* If the user is a twit, move to the twit room for posting... */
if (TWITDETECT) if (CC->usersupp.axlevel==2) {
- if (twitroom<0) loadtroom();
- hold_rm=CC->curr_rm;
- CC->curr_rm=twitroom;
+ strcpy(hold_rm, CC->cs_room);
+ strcpy(CC->cs_room, config.c_twitroom);
}
/* ...or if this message is destined for Aide> then go there. */
if (mtsflag) {
- hold_rm=CC->curr_rm;
- CC->curr_rm=2;
+ strcpy(hold_rm, CC->cs_room);
+ strcpy(CC->cs_room, "Aide");
}
+ /* ...or if this is a private message, go to the target mailbox. */
+ /* FIX FIX FIX do this! */
+
/* This call to usergoto() changes rooms if necessary. It also
* causes the latest message list to be read into memory.
*/
- usergoto(CC->curr_rm,0);
-
- /* Store the message pointer, but NOT for sent mail! */
- if (CC->curr_rm != 1) {
+ lprintf(9, "Changing rooms if necessary...\n");
+ usergoto(CC->cs_room, 0);
- /* read in the quickroom record, obtaining a lock... */
- lgetroom(&CC->quickroom,CC->curr_rm);
- get_msglist(CC->curr_rm);
+ /* read in the quickroom record, obtaining a lock... */
+ lprintf(9, "Reading/locking <%s>...\n", CC->cs_room);
+ lgetroom(&CC->quickroom, CC->cs_room);
+ lprintf(9, "Fetching message list...\n");
+ get_msglist(&CC->quickroom);
- /* FIX here's where we have to to message expiry!! */
+ /* FIX here's where we have to to message expiry!! */
- /* Now add the new message */
- CC->num_msgs = CC->num_msgs + 1;
- CC->msglist = realloc(CC->msglist,
- ((CC->num_msgs) * sizeof(long)) );
- if (CC->msglist == NULL) {
- lprintf(3, "ERROR can't realloc message list!\n");
- }
- SetMessageInList(CC->num_msgs - 1, newmsgid);
-
- /* Write it back to disk. */
- put_msglist(CC->curr_rm);
-
- /* update quickroom */
- CC->quickroom.QRhighest = newmsgid;
- lputroom(&CC->quickroom,CC->curr_rm);
+ /* Now add the new message */
+ CC->num_msgs = CC->num_msgs + 1;
+ CC->msglist = realloc(CC->msglist,
+ ((CC->num_msgs) * sizeof(long)) );
+ if (CC->msglist == NULL) {
+ lprintf(3, "ERROR can't realloc message list!\n");
}
+ SetMessageInList(CC->num_msgs - 1, newmsgid);
+
+ /* Write it back to disk. */
+ lprintf(9, "Writing message list...\n");
+ put_msglist(&CC->quickroom);
+
+ /* update quickroom */
+ CC->quickroom.QRhighest = newmsgid;
+ lprintf(9, "Writing/unlocking room <%s>...\n", CC->cs_room);
+ lputroom(&CC->quickroom,CC->cs_room);
/* Bump this user's messages posted counter. Also, if the user is a
* twit, give them access to the twit room.
*/
- lgetuser(&CC->usersupp,CC->curr_user);
+ lgetuser(&CC->usersupp, CC->curr_user);
CC->usersupp.posted = CC->usersupp.posted + 1;
/* FIX if user is twit, grant access to twitroom here */
lputuser(&CC->usersupp, CC->curr_user);
- /* If mail, there's still more to do, if not, skip it. */
- if ((CC->curr_rm!=1)||(mtsflag)) goto ENTFIN;
-
/* Network mail - send a copy to the network program. */
if (mailtype!=M_LOCAL) {
sprintf(aaa,"./network/spoolin/nm.%d",getpid());
system("exec nohup ./netproc >/dev/null 2>&1 &");
}
- /* Local mail - put a copy in the recipient's mailbox. */
- /* FIX here's where we have to handle expiry, stuffed boxes, etc. */
- if (mailtype == M_LOCAL) {
- if (lgetuser(&tempUS,rec)==0) {
-
- cdbmb = cdb_fetch(CDB_MAILBOXES,
- &tempUS.usernum, sizeof(long));
- if (cdbmb != NULL) {
- memcpy(dmailbox, cdbmb->ptr, cdbmb->len);
- dnum_mails = cdbmb->len / sizeof(long);
- cdb_free(cdbmb);
- }
- else {
- dmailbox = NULL;
- dnum_mails = 0;
- }
-
- ++dnum_mails;
- if (dmailbox == NULL) {
- dmailbox = malloc(sizeof(long) * dnum_mails);
- }
- else {
- dmailbox = realloc(dmailbox,
- sizeof(long) * dnum_mails);
- }
-
- dmailbox[dnum_mails - 1] = newmsgid;
- cdb_store(CDB_MAILBOXES, &tempUS.usernum, sizeof(long),
- dmailbox, (dnum_mails * sizeof(long)) );
- lputuser(&tempUS,rec);
- free(dmailbox);
- }
- }
-
/* If we've posted in a room other than the current room, then we
* have to now go back to the current room...
*/
-ENTFIN: if (hold_rm!=(-1)) {
- usergoto(hold_rm,0);
+ if (strlen(hold_rm) > 0) {
+ lprintf(9, "Returning to <%s>\n", hold_rm);
+ usergoto(hold_rm, 0);
}
+ lprintf(9, "Deleting temporary file\n");
unlink(mtmp); /* delete the temporary file */
+ lprintf(9, "Finished with save_message()\n");
}
char newusername[256]; /* <bc> */
char boundary[256];
- int a,b,e;
+ int a,b;
+ int e = 0;
int mtsflag = 0;
struct usersupp tempUS;
char buf[256];
cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No room selected.\n",ERROR);
- return;
- }
- if ((CC->usersupp.axlevel<2)&&(CC->curr_rm!=1)) {
- cprintf("%d Need to be validated to enter (except in Mail> to sysop)\n",
+ if ((CC->usersupp.axlevel<2)&&((CC->quickroom.QRflags&QR_MAILBOX)==0)) {
+ cprintf("%d Need to be validated to enter ",
ERROR+HIGHER_ACCESS_REQUIRED);
+ cprintf("(except in %s> to sysop)\n", MAILROOM);
return;
}
if ((CC->usersupp.axlevel<4)&&(CC->quickroom.QRflags&QR_NETWORK)) {
if (post==2) { /* <bc> */
if (CC->usersupp.axlevel<6)
{
- cprintf("%d\nYou don't have sufficient permission to do an aide post.\n", ERROR+HIGHER_ACCESS_REQUIRED);
+ cprintf("%d You don't have permission to do an aide post.\n",
+ ERROR+HIGHER_ACCESS_REQUIRED);
return;
}
extract(newusername,entargs,4);
CC->cs_flags |= CS_POSTING;
buf[0]=0;
- if (CC->curr_rm==1) {
+ if (CC->quickroom.QRflags & QR_MAILBOX) {
if (CC->usersupp.axlevel>=2) {
strcpy(buf,recipient);
}
SKFALL: b=MES_NORMAL;
if (CC->quickroom.QRflags&QR_ANONONLY) b=MES_ANON;
- if (CC->quickroom.QRflags&QR_ANON2) {
+ if (CC->quickroom.QRflags&QR_ANONOPT) {
if (anon_flag==1) b=MES_AN2;
}
- if (CC->curr_rm!=1) buf[0]=0;
+ if ((CC->quickroom.QRflags & QR_MAILBOX) == 0) buf[0]=0;
/* If we're only checking the validity of the request, return
* success without creating the message.
{
char recp[256];
char buf[256];
- int a, e;
+ int a;
+ int e = 0;
struct usersupp tempUS;
long msglen;
long bloklen;
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No room selected.\n",ERROR);
- return;
- }
-
- if (CC->curr_rm == 1) { /* If we're in Mail, check the recipient */
+ /* If we're in Mail, check the recipient */
+ if (CC->quickroom.QRflags & QR_MAILBOX) {
extract(recp, entargs, 1);
lprintf(9, "aliasing...\n");
e=alias(recp); /* alias and mail type */
}
delnum = atol(delstr);
- if (CC->curr_rm==1) {
+ if (CC->quickroom.QRflags & QR_MAILBOX) {
cprintf("%d Can't delete mail.\n",ERROR);
return;
}
/* get room records, obtaining a lock... */
- lgetroom(&CC->quickroom,CC->curr_rm);
- get_msglist(CC->curr_rm);
+ lgetroom(&CC->quickroom,CC->cs_room);
+ get_msglist(&CC->quickroom);
ok = 0;
if (CC->num_msgs > 0) for (a=0; a<(CC->num_msgs); ++a) {
CC->num_msgs = sort_msglist(CC->msglist, CC->num_msgs);
CC->quickroom.QRhighest = MessageFromList(CC->num_msgs - 1);
- put_msglist(CC->curr_rm);
- lputroom(&CC->quickroom,CC->curr_rm);
+ put_msglist(&CC->quickroom);
+ lputroom(&CC->quickroom,CC->cs_room);
if (ok==1) {
cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
cprintf("%d Message deleted.\n",OK);
/*
- * move a message to another room FIX Rework this to use name indices
+ * move a message to another room
*/
void cmd_move(char *args)
{
long num;
char targ[32];
int a;
- int targ_slot;
struct quickroom qtemp;
int foundit;
- struct cdbdata *cdbtarg;
- long *targmsgs;
- int targ_count;
num = extract_long(args,0);
extract(targ,args,1);
- if (CC->curr_rm < 0) {
- cprintf("%d no room\n",ERROR);
- return;
- }
-
getuser(&CC->usersupp,CC->curr_user);
if ((CC->usersupp.axlevel < 6)
&& (CC->usersupp.usernum != CC->quickroom.QRroomaide)) {
return;
}
- targ_slot = (-1);
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&qtemp,a);
- if (!strcasecmp(qtemp.QRname,targ)) {
- targ_slot = a;
- a = MAXROOMS;
- }
- }
- if (targ_slot < 0) {
+ if (getroom(&qtemp, targ) != 0) {
cprintf("%d '%s' does not exist.\n",ERROR,targ);
return;
}
/* yank the message out of the current room... */
- lgetroom(&CC->quickroom,CC->curr_rm);
- get_msglist(CC->curr_rm);
+ lgetroom(&CC->quickroom, CC->cs_room);
+ get_msglist(&CC->quickroom);
foundit = 0;
for (a=0; a<(CC->num_msgs); ++a) {
}
if (foundit) {
CC->num_msgs = sort_msglist(CC->msglist, CC->num_msgs);
- put_msglist(CC->curr_rm);
+ put_msglist(&CC->quickroom);
CC->quickroom.QRhighest = MessageFromList((CC->num_msgs)-1);
}
- lputroom(&CC->quickroom,CC->curr_rm);
+ lputroom(&CC->quickroom,CC->cs_room);
if (!foundit) {
cprintf("%d msg %ld does not exist.\n",ERROR,num);
return;
}
/* put the message into the target room */
- lgetroom(&qtemp,targ_slot);
- cdbtarg = cdb_fetch(CDB_MSGLISTS, &targ_slot, sizeof(int));
- if (cdbtarg != NULL) {
- targmsgs = malloc(cdbtarg->len);
- memcpy(targmsgs, cdbtarg->ptr, cdbtarg->len);
- targ_count = cdbtarg->len / sizeof(long);
- cdb_free(cdbtarg);
- }
- else {
- targmsgs = NULL;
- targ_count = 0;
- }
- ++targ_count;
- targmsgs = realloc(targmsgs, ((CC->num_msgs) * sizeof(long)));
- targmsgs[targ_count - 1] = num;
- targ_count = sort_msglist(targmsgs, targ_count);
- qtemp.QRhighest = targmsgs[targ_count - 1];
- cdb_store(CDB_MSGLISTS, &targ_slot, sizeof(int),
- targmsgs, targ_count * sizeof(long));
- free(targmsgs);
- lputroom(&qtemp,targ_slot);
- cprintf("%d ok\n",OK);
+ cprintf("%d FIX FIX FIX implement this!!!!!\n", ERROR);
}
void get_config(void);
struct config config;
-char temp[20];
+char temp[32];
char ALIASES[128];
char CIT86NET[128];
struct msglist {
struct msglist *next;
long m_num;
- char m_rmname[20];
+ char m_rmname[ROOMNAMELEN];
};
struct rmlist {
struct rmlist *next;
- char rm_name[20];
+ char rm_name[ROOMNAMELEN];
long rm_lastsent;
};
#include <string.h>
#include <pthread.h>
#include <time.h>
+#include <limits.h>
#include "citadel.h"
#include "server.h"
#include "database.h"
return(retval);
}
-/*************** START OF OLD ROOM DATABASE FUNCTIONS ***********************/
/*
* getroom() - retrieve room data from disk
*/
-void getroom(struct quickroom *qrbuf, int room_num)
+int getroom(struct quickroom *qrbuf, char *room_name)
{
struct cdbdata *cdbqr;
- int a;
-
- bzero(qrbuf, sizeof(struct quickroom));
- cdbqr = cdb_fetch(CDB_QUICKROOM, &room_num, sizeof(int));
- if (cdbqr != NULL) {
- memcpy(qrbuf, cdbqr->ptr,
- ( (cdbqr->len > sizeof(struct quickroom)) ?
- sizeof(struct quickroom) : cdbqr->len) );
- cdb_free(cdbqr);
- }
- else {
- if (room_num < 3) {
- qrbuf->QRflags = QR_INUSE;
- time(&qrbuf->QRgen);
- switch(room_num) {
- case 0: strcpy(qrbuf->QRname, "Lobby");
- break;
- case 1: strcpy(qrbuf->QRname, "Mail");
- break;
- case 2: strcpy(qrbuf->QRname, "Aide");
- break;
- }
- }
- }
-
-
- /** FIX ** VILE SLEAZY HACK ALERT!!
- * This is a temporary fix until we can track down where room names
- * are getting corrupted on some systems.
- */
- for (a=0; a<20; ++a) if (qrbuf->QRname[a] < 32) qrbuf->QRname[a] = 0;
- qrbuf->QRname[19] = 0;
- }
-
-/*
- * lgetroom() - same as getroom() but locks the record (if supported)
- */
-void lgetroom(struct quickroom *qrbuf, int room_num)
-{
- begin_critical_section(S_QUICKROOM);
- getroom(qrbuf,room_num);
- }
-
-
-/*
- * putroom() - store room data on disk
- */
-void putroom(struct quickroom *qrbuf, int room_num)
-{
- time(&qrbuf->QRmtime);
- cdb_store(CDB_QUICKROOM, &room_num, sizeof(int),
- qrbuf, sizeof(struct quickroom));
- }
-
-
-/*
- * lputroom() - same as putroom() but unlocks the record (if supported)
- */
-void lputroom(struct quickroom *qrbuf, int room_num)
-{
-
- putroom(qrbuf,room_num);
- end_critical_section(S_QUICKROOM);
-
- }
-
-
-/*************** START OF NEW ROOM DATABASE FUNCTIONS ***********************/
-/*
- * ngetroom() - retrieve room data from disk
- */
-void ngetroom(struct quickroom *qrbuf, char *room_name)
-{
- struct cdbdata *cdbqr;
- char lowercase_name[20];
+ char lowercase_name[ROOMNAMELEN];
int a;
for (a=0; a<=strlen(room_name); ++a) {
( (cdbqr->len > sizeof(struct quickroom)) ?
sizeof(struct quickroom) : cdbqr->len) );
cdb_free(cdbqr);
+ return(0);
+ }
+ else {
+ return(1);
}
-
- /** FIX ** VILE SLEAZY HACK ALERT!!
- * This is a temporary fix until we can track down where room names
- * are getting corrupted on some systems.
- */
- for (a=0; a<20; ++a) if (qrbuf->QRname[a] < 32) qrbuf->QRname[a] = 0;
- qrbuf->QRname[19] = 0;
}
/*
- * lngetroom() - same as ngetroom() but locks the record (if supported)
+ * lgetroom() - same as getroom() but locks the record (if supported)
*/
-void lngetroom(struct quickroom *qrbuf, char *room_name)
+int lgetroom(struct quickroom *qrbuf, char *room_name)
{
begin_critical_section(S_QUICKROOM);
- ngetroom(qrbuf, room_name);
+ return(getroom(qrbuf, room_name));
}
/*
- * nputroom() - store room data on disk
+ * putroom() - store room data on disk
*/
-void nputroom(struct quickroom *qrbuf, char *room_name)
+void putroom(struct quickroom *qrbuf, char *room_name)
{
- char lowercase_name[20];
+ char lowercase_name[ROOMNAMELEN];
int a;
for (a=0; a<=strlen(room_name); ++a) {
/*
- * lnputroom() - same as nputroom() but unlocks the record (if supported)
+ * lputroom() - same as putroom() but unlocks the record (if supported)
*/
-void lnputroom(struct quickroom *qrbuf, char *room_name)
+void lputroom(struct quickroom *qrbuf, char *room_name)
{
- nputroom(qrbuf, room_name);
+ putroom(qrbuf, room_name);
end_critical_section(S_QUICKROOM);
}
/*
* get_msglist() - retrieve room message pointers
*/
-void get_msglist(int room_num)
-{
+void get_msglist(struct quickroom *whichroom) {
struct cdbdata *cdbfr;
+ char dbkey[256];
+ int a;
+
+ sprintf(dbkey, "%s%ld", whichroom->QRname, whichroom->QRgen);
+ for (a=0; a<strlen(dbkey); ++a) dbkey[a]=tolower(dbkey[a]);
if (CC->msglist != NULL) {
free(CC->msglist);
CC->msglist = NULL;
CC->num_msgs = 0;
- if (room_num != 1) {
- cdbfr = cdb_fetch(CDB_MSGLISTS, &room_num, sizeof(int));
- }
- else {
- cdbfr = cdb_fetch(CDB_MAILBOXES, &CC->usersupp.usernum,
- sizeof(long));
- }
+ cdbfr = cdb_fetch(CDB_MSGLISTS, dbkey, strlen(dbkey));
if (cdbfr == NULL) {
return;
/*
* put_msglist() - retrieve room message pointers
*/
-void put_msglist(int room_num)
-{
+void put_msglist(struct quickroom *whichroom) {
+ char dbkey[256];
+ int a;
- if (room_num != 1) {
- cdb_store(CDB_MSGLISTS, &room_num, sizeof(int),
- CC->msglist, (CC->num_msgs * sizeof(long)) );
- }
- else {
- cdb_store(CDB_MAILBOXES, &CC->usersupp.usernum, sizeof(long),
- CC->msglist, (CC->num_msgs * sizeof(long)) );
- }
+ sprintf(dbkey, "%s%ld", whichroom->QRname, whichroom->QRgen);
+ for (a=0; a<strlen(dbkey); ++a) dbkey[a]=tolower(dbkey[a]);
+
+ cdb_store(CDB_MSGLISTS, dbkey, strlen(dbkey),
+ CC->msglist, CC->num_msgs * sizeof(long));
+ }
+
+
+/*
+ * delete_msglist() - delete room message pointers
+ */
+void delete_msglist(struct quickroom *whichroom) {
+ char dbkey[256];
+ int a;
+
+ sprintf(dbkey, "%s%ld", whichroom->QRname, whichroom->QRgen);
+ for (a=0; a<strlen(dbkey); ++a) dbkey[a]=tolower(dbkey[a]);
+
+ cdb_delete(CDB_MSGLISTS, dbkey, strlen(dbkey));
}
-void usergoto(int where, int display_result)
+void usergoto(char *where, int display_result)
{
int a;
int new_messages = 0;
int newmailcount = 0;
struct visit vbuf;
- CC->curr_rm=where;
- getroom(&CC->quickroom,CC->curr_rm);
+ strcpy(CC->cs_room, where);
+ getroom(&CC->quickroom, CC->cs_room);
lgetuser(&CC->usersupp,CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
if (CC->quickroom.QRinfo > vbuf.v_lastseen) info = 1;
get_mm();
- get_msglist(CC->curr_rm);
+ get_msglist(&CC->quickroom);
for (a=0; a<CC->num_msgs; ++a) {
if (MessageFromList(a)>0L) {
++total_messages;
}
- if (CC->curr_rm == 1) rmailflag = 1;
+ if (0) rmailflag = 1; /* FIX to handle mail rooms!!! */
else rmailflag = 0;
if ( (CC->quickroom.QRroomaide == CC->usersupp.usernum)
void cmd_goto(char *gargs)
{
struct quickroom QRscratch;
- int a,c;
- int ok, ra;
- char bbb[20],towhere[32],password[20];
+ int c;
+ int ok = 0;
+ int ra;
+ char bbb[ROOMNAMELEN],towhere[32],password[20];
if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
cprintf("%d not logged in\n",ERROR+NOT_LOGGED_IN);
c=0;
getuser(&CC->usersupp,CC->curr_user);
- /* FIX This is the primary bit of code that needs to be rewritten
- * during the cutover. Search for rooms by name rather than by
- * position in the file. A total rewrite may be necessary.
- */
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&QRscratch,a);
- if ((a==0)&&(!strcasecmp(towhere,"_BASEROOM_"))) {
- strncpy(towhere,QRscratch.QRname,31);
- }
- if ((a==1)&&(!strcasecmp(towhere,"_MAIL_"))) {
- strncpy(towhere,QRscratch.QRname,31);
- }
- if ((!strcasecmp(QRscratch.QRname,config.c_twitroom))
- &&(!strcasecmp(towhere,"_BITBUCKET_"))) {
- strncpy(towhere,QRscratch.QRname,31);
- }
- strcpy(bbb,QRscratch.QRname);
- ok = 0;
+ if (!strcasecmp(towhere, "_BASEROOM_"))
+ strcpy(towhere, BASEROOM);
- /* let internal programs go directly to any room */
- if (((CC->internal_pgm))&&(!strcasecmp(bbb,towhere))) {
- usergoto(a,1);
- return;
- }
+ if (!strcasecmp(towhere, "_MAIL_"))
+ strcpy(towhere, MAILROOM);
- if (!strcasecmp(bbb, towhere)) {
+ if (!strcasecmp(towhere, "_BITBUCKET_"))
+ strcpy(towhere, config.c_twitroom);
- /* See if there is an existing user/room relationship */
- ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
-
- /* normal clients have to pass through security */
- if (ra & UA_GOTOALLOWED) ok = 1;
-
- if (ok==1) {
- if ( (QRscratch.QRflags&QR_PASSWORDED) &&
- ((ra & UA_KNOWN) == 0) &&
- (strcasecmp(QRscratch.QRpasswd,password))
- ) {
- cprintf("%d wrong or missing passwd\n",
- ERROR+PASSWORD_REQUIRED);
- return;
- }
- else {
- usergoto(a,1);
+
+ /* let internal programs go directly to any room */
+ if (((CC->internal_pgm))&&(!strcasecmp(bbb,towhere))) {
+ usergoto(towhere, 1);
+ return;
+ }
+
+ if (getroom(&QRscratch, towhere) == 0) {
+
+ /* See if there is an existing user/room relationship */
+ ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
+
+ /* normal clients have to pass through security */
+ if (ra & UA_GOTOALLOWED) ok = 1;
+
+ if (ok==1) {
+ if ( (QRscratch.QRflags&QR_PASSWORDED) &&
+ ((ra & UA_KNOWN) == 0) &&
+ (strcasecmp(QRscratch.QRpasswd,password))
+ ) {
+ cprintf("%d wrong or missing passwd\n",
+ ERROR+PASSWORD_REQUIRED);
return;
}
+ else {
+ usergoto(towhere, 1);
+ return;
}
}
}
-
+
cprintf("%d room '%s' not found\n",ERROR+ROOM_NOT_FOUND,towhere);
}
return;
}
- getroom(&CC->quickroom,CC->curr_rm);
- getuser(&CC->usersupp,CC->curr_user);
+ getroom(&CC->quickroom, CC->cs_room);
+ getuser(&CC->usersupp, CC->curr_user);
if ((CC->quickroom.QRflags & QR_DIRECTORY) == 0) {
cprintf("%d not here.\n",ERROR+NOT_HERE);
return;
}
- if (CC->curr_rm < 3) {
+ if ( (!strcasecmp(CC->cs_room, BASEROOM))
+ || (!strcasecmp(CC->cs_room, AIDEROOM)) ) {
cprintf("%d Can't edit this room.\n",ERROR+NOT_HERE);
return;
}
- getroom(&CC->quickroom,CC->curr_rm);
+ getroom(&CC->quickroom, CC->cs_room);
cprintf("%d%c%s|%s|%s|%d|%d\n",
OK,check_express(),
CC->quickroom.QRname,
return;
}
- if (CC->curr_rm < 3) {
+ if ( (!strcasecmp(CC->cs_room, BASEROOM))
+ || (!strcasecmp(CC->cs_room, AIDEROOM)) ) {
cprintf("%d Can't edit this room.\n",ERROR+NOT_HERE);
return;
}
}
}
- lgetroom(&CC->quickroom,CC->curr_rm);
- extract(buf,args,0); buf[20]=0;
- strncpy(CC->quickroom.QRname,buf,19);
+ lgetroom(&CC->quickroom, CC->cs_room);
+ extract(buf,args,0); buf[ROOMNAMELEN]=0;
+ strncpy(CC->quickroom.QRname,buf,ROOMNAMELEN-1);
extract(buf,args,1); buf[10]=0;
strncpy(CC->quickroom.QRpasswd,buf,9);
extract(buf,args,2); buf[15]=0;
CC->quickroom.QRfloor = extract_int(args,5);
}
- lputroom(&CC->quickroom,CC->curr_rm);
+ lputroom(&CC->quickroom, CC->cs_room);
/* adjust the floor reference counts */
lgetfloor(&flbuf,old_floor);
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No current room.\n",ERROR);
+ if ( (!strcasecmp(CC->cs_room, BASEROOM))
+ || (!strcasecmp(CC->cs_room, AIDEROOM)) ) {
+ cprintf("%d Can't edit this room.\n",ERROR+NOT_HERE);
return;
}
return;
}
- if (CC->curr_rm < 3) {
- cprintf("%d Can't edit this room.\n",ERROR+NOT_HERE);
- return;
- }
-
if (getuser(&usbuf,new_ra)!=0) {
newu = (-1L);
}
newu = usbuf.usernum;
}
- lgetroom(&CC->quickroom,CC->curr_rm);
+ lgetroom(&CC->quickroom, CC->cs_room);
post_notice = 0;
if (CC->quickroom.QRroomaide != newu) {
post_notice = 1;
}
CC->quickroom.QRroomaide = newu;
- lputroom(&CC->quickroom,CC->curr_rm);
+ lputroom(&CC->quickroom, CC->cs_room);
/*
* We have to post the change notice _after_ writing changes to
cprintf("%d Ok\n",OK);
}
+/*
+ * Generate an associated file name for a room
+ */
+void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix) {
+ int a;
+
+ sprintf(buf, "./prefix/%s.%ld", qrbuf->QRname, qrbuf->QRgen);
+ for (a=0; a<strlen(buf); ++a) {
+ if (buf[a]==32) buf[a]='.';
+ }
+ }
/*
* retrieve info file for this room
*/
void cmd_rinf(void) {
- char filename[64];
+ char filename[128];
char buf[256];
FILE *info_fp;
- sprintf(filename,"./info/%d",CC->curr_rm);
+ assoc_file_name(filename, &CC->quickroom, "info");
info_fp = fopen(filename,"r");
if (info_fp==NULL) {
return;
}
- if (CC->curr_rm < 3) {
- cprintf("%d Can't kill this room.\n",ERROR+NOT_HERE);
+ if ( (!strcasecmp(CC->cs_room, BASEROOM))
+ || (!strcasecmp(CC->cs_room, AIDEROOM)) ) {
+ cprintf("%d Can't edit this room.\n",ERROR+NOT_HERE);
return;
}
if (kill_ok) {
+ /* Delete the info file */
+ assoc_file_name(aaa, &CC->quickroom, "info");
+ unlink(aaa);
+
/* first flag the room record as not in use */
- lgetroom(&CC->quickroom,CC->curr_rm);
+ lgetroom(&CC->quickroom, CC->cs_room);
CC->quickroom.QRflags=0;
/* then delete the messages in the room */
- get_msglist(CC->curr_rm);
+ get_msglist(&CC->quickroom);
if (CC->num_msgs > 0) for (a=0; a < CC->num_msgs; ++a) {
MsgToDelete = MessageFromList(a);
cdb_delete(CDB_MSGMAIN, &MsgToDelete, sizeof(long));
}
- put_msglist(CC->curr_rm);
+ put_msglist(&CC->quickroom);
free(CC->msglist);
CC->num_msgs = 0;
- cdb_delete(CDB_MSGLISTS, &CC->curr_rm, sizeof(int));
-
- lputroom(&CC->quickroom,CC->curr_rm);
+ delete_msglist(&CC->quickroom);
+ lputroom(&CC->quickroom, CC->cs_room);
+ /* FIX FIX FIX
+ * To do at this location in the code:
+ * 1. Delete the associated files (info, image)
+ * 2. Delete the room record from the database
+ */
/* then decrement the reference count for the floor */
lgetfloor(&flbuf,(int)CC->quickroom.QRfloor);
/* tell the world what we did */
sprintf(aaa,"%s> killed by %s",CC->quickroom.QRname,CC->curr_user);
aide_message(aaa);
- CC->curr_rm=(-1);
+ usergoto(BASEROOM, 0);
cprintf("%d '%s' deleted.\n",OK,CC->quickroom.QRname);
}
else {
/*
- * Find a free slot to create a new room in, or return -1 for error.
- * search_dir is the direction to search in. 1 causes this function to
- * return the first available slot, -1 gets the last available slot.
+ * Internal code to create a new room (returns room flags)
*
- * FIX This function can be eliminated during the cutover.
+ * Room types: 0=public, 1=guessname, 2=passworded, 3=inv-only, 4=mailbox
*/
-int get_free_room_slot(int search_dir)
-{
- int a,st;
- struct quickroom qrbuf;
-
- st = ((search_dir>0) ? 3 : (MAXROOMS-1));
-
- for (a=st; ((a<MAXROOMS)&&(a>=3)); a=a+search_dir) {
- getroom(&qrbuf,a);
- if ((qrbuf.QRflags & QR_INUSE)==0) return(a);
- }
- return(-1);
- }
+unsigned create_room(char *new_room_name,
+ int new_room_type,
+ char *new_room_pass,
+ int new_room_floor) {
-
-/*
- * internal code to create a new room (returns room flags)
- */
-unsigned create_room(int free_slot, char *new_room_name, int new_room_type, char *new_room_pass, int new_room_floor)
-{
struct quickroom qrbuf;
struct floor flbuf;
struct visit vbuf;
- lgetroom(&qrbuf,free_slot);
- strncpy(qrbuf.QRname,new_room_name,19);
+ if (getroom(&qrbuf, new_room_name)==0) return(0); /* already exists */
+
+ bzero(&qrbuf, sizeof(struct quickroom));
+ strncpy(qrbuf.QRname,new_room_name,ROOMNAMELEN);
strncpy(qrbuf.QRpasswd,new_room_pass,9);
qrbuf.QRflags = QR_INUSE;
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 == 4) qrbuf.QRflags=(qrbuf.QRflags|QR_MAILBOX);
qrbuf.QRroomaide = (-1L);
if ((new_room_type > 0)&&(CREATAIDE==1))
qrbuf.QRroomaide=CC->usersupp.usernum;
qrbuf.QRfloor = new_room_floor;
/* save what we just did... */
- lputroom(&qrbuf,free_slot);
+ putroom(&qrbuf, qrbuf.QRname);
/* bump the reference count on whatever floor the room is on */
lgetfloor(&flbuf,(int)qrbuf.QRfloor);
/*
- * create a new room FIX Rework this to use name indexing
+ * create a new room
*/
void cmd_cre8(char *args)
{
int cre8_ok;
- int free_slot;
- int a;
char new_room_name[256];
int new_room_type;
char new_room_pass[256];
cre8_ok = extract_int(args,0);
extract(new_room_name,args,1);
- new_room_name[19] = 0;
+ new_room_name[ROOMNAMELEN-1] = 0;
new_room_type = extract_int(args,2);
extract(new_room_pass,args,3);
new_room_pass[9] = 0;
return;
}
- free_slot = get_free_room_slot(1);
- if (free_slot<0) {
- cprintf("%d There is no space available for a new room.\n",
- ERROR);
+ if ((strlen(new_room_name)==0) && (cre8_ok==0)) {
+ cprintf("%d Ok to create rooms.\n", OK);
return;
}
- if (cre8_ok==0) {
- cprintf("%d ok to create...\n",OK);
+ /* Check to make sure the requested room name doesn't already exist */
+ if (getroom(&qrbuf, new_room_name)==0) {
+ cprintf("%d '%s' already exists.\n",
+ ERROR,qrbuf.QRname);
return;
}
- for (a=0; a<MAXROOMS; ++a) {
- getroom(&qrbuf,a);
- if ( (!strcasecmp(qrbuf.QRname,new_room_name))
- && (qrbuf.QRflags & QR_INUSE) ) {
- cprintf("%d '%s' already exists.\n",
- ERROR,qrbuf.QRname);
- return;
- }
- }
-
if ((new_room_type < 0) || (new_room_type > 3)) {
cprintf("%d Invalid room type.\n",ERROR);
return;
}
- newflags = create_room(free_slot,new_room_name,
+ if (cre8_ok == 0) {
+ cprintf("%d OK to create '%s'\n", OK, new_room_name);
+ return;
+ }
+
+ newflags = create_room(new_room_name,
new_room_type,new_room_pass,new_room_floor);
/* post a message in Aide> describing the new room */
}
aide_message(aaa);
- sprintf(aaa,"./info/%d",free_slot); /* delete old info file */
- unlink(aaa);
- sprintf(aaa,"./images/room.%d.gif",free_slot); /* and picture */
- unlink(aaa);
-
cprintf("%d '%s' has been created.\n",OK,qrbuf.QRname);
}
void cmd_einf(char *ok)
{ /* enter info file for current room */
FILE *fp;
- char infofilename[32];
+ char infofilename[64];
char buf[256];
if (!(CC->logged_in)) {
cprintf("%d Send info...\n",SEND_LISTING);
- sprintf(infofilename,"./info/%d",CC->curr_rm);
+ assoc_file_name(infofilename, &CC->quickroom, "info");
fp=fopen(infofilename,"w");
do {
fclose(fp);
/* now update the room index so people will see our new info */
- lgetroom(&CC->quickroom,CC->curr_rm); /* lock so no one steps on us */
+ lgetroom(&CC->quickroom,CC->cs_room); /* lock so no one steps on us */
CC->quickroom.QRinfo = CC->quickroom.QRhighest + 1L;
- lputroom(&CC->quickroom,CC->curr_rm);
+ lputroom(&CC->quickroom,CC->cs_room);
}
struct usersupp *userbuf);
int is_zapped (struct quickroom *roombuf, int roomnum,
struct usersupp *userbuf);
-void getroom (struct quickroom *qrbuf, int room_num);
-void lgetroom (struct quickroom *qrbuf, int room_num);
-void putroom (struct quickroom *qrbuf, int room_num);
-void lputroom (struct quickroom *qrbuf, int room_num);
+int getroom(struct quickroom *qrbuf, char *room_name);
+void putroom(struct quickroom *qrbuf, char *room_name);
+int lgetroom(struct quickroom *qrbuf, char *room_name);
+void lputroom(struct quickroom *qrbuf, char *room_name);
void getfloor (struct floor *flbuf, int floor_num);
void lgetfloor (struct floor *flbuf, int floor_num);
void putfloor (struct floor *flbuf, int floor_num);
void lputfloor (struct floor *flbuf, int floor_num);
-void get_msglist (int room_num);
-void put_msglist (int room_num);
+void get_msglist (struct quickroom *whichroom);
+void put_msglist (struct quickroom *whichroom);
long int MessageFromList (int whichpos);
void SetMessageInList (int whichpos, long int newmsgnum);
int sort_msglist (long int *listptrs, int oldcount);
void cmd_lkrn (char *argbuf);
void cmd_lkro (char *argbuf);
void cmd_lzrm (char *argbuf);
-void usergoto (int where, int display_result);
+void usergoto (char *where, int display_result);
void cmd_goto (char *gargs);
void cmd_whok (void);
void cmd_rdir (void);
void cmd_seta (char *new_ra);
void cmd_rinf (void);
void cmd_kill (char *argbuf);
-int get_free_room_slot (int search_dir);
-unsigned int create_room (int free_slot, char *new_room_name,
- int new_room_type, char *new_room_pass,
- int new_room_floor);
+unsigned create_room(char *new_room_name,
+ int new_room_type,
+ char *new_room_pass,
+ int new_room_floor);
void cmd_cre8 (char *args);
void cmd_einf (char *ok);
void cmd_lflr (void);
void cmd_kflr (char *argbuf);
void cmd_eflr (char *argbuf);
void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom));
+void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix);
* .<A>ide <E>dit room
*/
void editthisroom(void) {
- char rname[20];
+ char rname[ROOMNAMELEN];
char rpass[10];
char rdir[15];
unsigned rflags;
else strcpy(raide,"");
if (strlen(raide)==0) strcpy(raide,"none");
- strprompt("Room name",rname,19);
+ strprompt("Room name",rname,ROOMNAMELEN-1);
rfloor = select_floor(rfloor);
rflags = set_room_attr(rflags,"Private room",QR_PRIVATE);
if ( (rflags & QR_ANONONLY) == 0) {
rflags = set_room_attr(rflags,
"Ask users whether to make messages anonymous",
- QR_ANON2);
+ QR_ANONOPT);
}
do {
*/
void entroom(void) {
char cmd[256];
- char new_room_name[20];
+ char new_room_name[ROOMNAMELEN];
int new_room_type;
char new_room_pass[10];
int new_room_floor;
return;
}
- newprompt("Name for new room? ",new_room_name,19);
+ newprompt("Name for new room? ",new_room_name,ROOMNAMELEN-1);
if (strlen(new_room_name)==0) return;
for (a=0; a<strlen(new_room_name); ++a)
if (new_room_name[a] == '|') new_room_name[a]='_';
*/
void movefile(void) {
char filename[64];
- char newroom[20];
+ char newroom[ROOMNAMELEN];
char cmd[256];
newprompt("Filename: ",filename,63);
if (strlen(filename)==0) return;
- newprompt("Enter target room: ",newroom,19);
+ newprompt("Enter target room: ",newroom,ROOMNAMELEN-1);
sprintf(cmd,"MOVF %s|%s",filename,newroom);
serv_puts(cmd);
#include <sys/time.h>
#include <sys/wait.h>
#include <string.h>
+#include <limits.h>
#include <pthread.h>
#include "citadel.h"
#include "server.h"
time(&now);
clnew->next = NULL;
clnew->chat_time = now;
- strncpy(clnew->chat_room, roomname, 19);
+ strncpy(clnew->chat_room, roomname, ROOMNAMELEN-1);
if (username)
strncpy(clnew->chat_username, username, 31);
else
char cmdbuf[256];
char *un;
char *strptr1;
- char hold_cs_room[20];
+ char hold_cs_room[ROOMNAMELEN];
int MyLastMsg, ThisLastMsg;
struct ChatLine *clptr;
struct CitContext *t_context;
strcpy(CC->chat_room, "Main room");
else
{
- strncpy(CC->chat_room, &cmdbuf[6], 20);
+ strncpy(CC->chat_room, &cmdbuf[6], ROOMNAMELEN);
}
allwrite("<joining room>",0, CC->chat_room, NULL);
cprintf("\n");
{
if ((clptr->chat_seq > MyLastMsg) && ((!clptr->chat_username[0]) || (!strncasecmp(un, clptr->chat_username, 32))))
{
- if ((!clptr->chat_room[0]) || (!strncasecmp(CC->chat_room, clptr->chat_room, 20)))
+ if ((!clptr->chat_room[0]) || (!strncasecmp(CC->chat_room, clptr->chat_room, ROOMNAMELEN)))
{
cprintf("%s\n", clptr->chat_text);
}
#include <sys/time.h>
#include <sys/wait.h>
#include <string.h>
+#include <limits.h>
#include <pthread.h>
#include "citadel.h"
#include "server.h"
-
typedef pthread_t THREAD;
int num_msgs;
char curr_user[32]; /* name of current user */
- int curr_rm; /* index of current room */
int logged_in; /* logged in */
int internal_pgm; /* authenticated as internal program */
char temp[32]; /* temp file name */
/*** STRUCTURE SIZE VARIABLES ***/
-/* You may NOT change these values once you set up your system. */
-#define MAXROOMS 128 /* Number of rooms in system */
+/* You may NOT change this value once you set up your system. */
#define MAXFLOORS 16 /* Do not set higher than 127 */
/*** END OF STRUCTURE SIZE VARIABLES ***/
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <limits.h>
#include <netinet/in.h>
#include <netdb.h>
#include <string.h>
free(visits);
}
-
+
+
+void MailboxName(char *buf, struct usersupp *who, char *prefix) {
+ sprintf(buf, "%010ld.%s", who->usernum, prefix);
+ }
+
/*
* Is the user currently logged in an Aide?
cprintf("%d %s|%d|%d|%d|%u|%ld\n",OK,CC->usersupp.fullname,CC->usersupp.axlevel,
CC->usersupp.timescalled,CC->usersupp.posted,CC->usersupp.flags,
CC->usersupp.usernum);
- usergoto(0,0); /* Enter the lobby */
+ usergoto(BASEROOM,0); /* Enter the lobby */
rec_log(CL_LOGIN,CC->curr_user);
}
int a;
struct passwd *p = NULL;
char username[64];
+ char mailboxname[ROOMNAMELEN];
strcpy(username, newusername);
strproc(username);
if (getuser(&CC->usersupp,CC->curr_user)) {
return(ERROR+INTERNAL_ERROR);
}
+
+ /* give the user a private mailbox */
+ MailboxName(mailboxname, &CC->usersupp, MAILROOM);
+ create_room(mailboxname, 4, "", 0);
+
rec_log(CL_NEWUSER,CC->curr_user);
return(0);
}
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No current room.\n",ERROR);
- return;
- }
-
if (!strncasecmp(new_ptr,"highest",7)) {
newlr = CC->quickroom.QRhighest;
-/* FIX ... if the current room is 1 (Mail), newlr needs to be set to the
- * number of the highest mail message
- */
}
else {
newlr = atol(new_ptr);
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No current room.\n",ERROR);
- return;
- }
-
if (is_room_aide()==0) {
cprintf("%d Higher access required.\n",
ERROR+HIGHER_ACCESS_REQUIRED);
return;
}
- if (CC->curr_rm < 0) {
- cprintf("%d No current room.\n",ERROR);
- return;
- }
-
- if (CC->curr_rm < 3) {
- cprintf("%d You cannot forget this room.\n",ERROR+NOT_HERE);
- return;
- }
-
if (is_aide()) {
cprintf("%d Aides cannot forget rooms.\n",ERROR);
return;
CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
lputuser(&CC->usersupp,CC->curr_user);
cprintf("%d Ok\n",OK);
- CC->curr_rm = (-1);
+ usergoto(BASEROOM, 0);
}
/*
int num_mails;
long *mailbox;
int a;
+ char mailboxname[32];
+
+ MailboxName(mailboxname, &CC->usersupp, MAILROOM);
+ for (a=0; a<=strlen(mailboxname); ++a) {
+ mailboxname[a] = tolower(mailboxname[a]);
+ }
- cdbmb = cdb_fetch(CDB_MAILBOXES, &CC->usersupp.usernum, sizeof(long));
+ cdbmb = cdb_fetch(CDB_MAILBOXES, mailboxname, strlen(mailboxname));
if (cdbmb != NULL) {
num_mails = cdbmb->len / sizeof(long);
mailbox = (long *) cdbmb->ptr;