]> code.citadel.org Git - citadel.git/commitdiff
* Finally removed all three usersupp.foo[MAXROOMS] elements, and
authorArt Cancro <ajc@citadel.org>
Fri, 2 Oct 1998 04:06:25 +0000 (04:06 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 2 Oct 1998 04:06:25 +0000 (04:06 +0000)
          migrated all the code that used them to use "struct visit" instead.

citadel/ChangeLog
citadel/citadel.h
citadel/msgbase.c
citadel/room_ops.c
citadel/techdoc/citadelapi.txt
citadel/user_ops.c

index c0000513d13b7d114a6f1d5697041c695d5e13fd..d688c713d444c4830e391b18a1b6fe4130138ace 100644 (file)
@@ -1,3 +1,7 @@
+Fri Oct  2 00:04:31 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * Finally removed all three usersupp.foo[MAXROOMS] elements, and
+         migrated all the code that used them to use "struct visit" instead.
+
 Thu Oct  1 23:02:20 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Rewrote [l][get|put]room() functions to use room names rather than
          room index numbers.  Temporarily prepended a "n" to these four
index d0b014363ef844f57a56d7c3305eb4bf1ce9032d..559fe56e022b6061b0a699b366d0294b9e249c65 100644 (file)
@@ -87,9 +87,6 @@ struct visit {
 struct usersupp {                      /* User record                      */
        int USuid;                      /* userid (==BBSUID for bbs only)   */
        char password[20];              /* password (for BBS-only users)    */
-       long lastseen[MAXROOMS];        /*      deprecated                  */
-       long generation[MAXROOMS];      /*      deprecated                  */
-       long forget[MAXROOMS];          /*      deprecated                  */
        unsigned flags;                 /* See US_ flags below              */
        int timescalled;                /* Total number of logins           */
        int posted;                     /* Number of messages posted (ever) */
index 1bf0f8b0d758f118fde46c3d3ed141cae2cb81a6..009214aa6ed64febbc52d10a4525c0110f77c015 100644 (file)
@@ -801,9 +801,7 @@ void save_message(char *mtmp,       /* file containing proper message */
         */
        lgetuser(&CC->usersupp,CC->curr_user);
        CC->usersupp.posted = CC->usersupp.posted + 1;
-       if (CC->curr_rm==twitroom) {
-               CC->usersupp.generation[twitroom] = CC->quickroom.QRgen;
-               }
+       /* 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. */
index 8a35e5fc0bae036d32b8f59dfa356d3d87856603..1e3df6ffa858877314ade57ba33adc1b0a2c64fb 100644 (file)
@@ -630,11 +630,6 @@ void usergoto(int where, int display_result)
        lgetuser(&CC->usersupp,CC->curr_user);
        CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
 
-       /* old method - remove when we're ready */
-       CC->usersupp.forget[CC->curr_rm]=(-1);
-       CC->usersupp.generation[CC->curr_rm]=CC->quickroom.QRgen;
-
-       /* new method */
        vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
        vbuf.v_flags = vbuf.v_flags | V_ACCESS;
 
@@ -691,7 +686,7 @@ void cmd_goto(char *gargs)
 {
        struct quickroom QRscratch;
        int a,c;
-       int ok;
+       int ok, ra;
        char bbb[20],towhere[32],password[20];
 
        if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
@@ -730,44 +725,31 @@ void cmd_goto(char *gargs)
                        return;
                        }
 
-               /* normal clients have to pass through security */
-               if ( 
-                       (strcasecmp(bbb,towhere)==0)
-                       &&      ((QRscratch.QRflags&QR_INUSE)!=0)
-
-                       && (    ((QRscratch.QRflags&QR_PREFONLY)==0)
-                       ||      (CC->usersupp.axlevel>=5)
-                       )
+               if (!strcasecmp(bbb, towhere)) {
 
-                       && (    (a!=2) || (CC->usersupp.axlevel>=6) )
-
-                       && (    ((QRscratch.QRflags&QR_PRIVATE)==0)
-                       || (QRscratch.QRflags&QR_GUESSNAME)
-                       || (CC->usersupp.axlevel>=6)
-                       || (QRscratch.QRflags&QR_PASSWORDED)
-                       ||      (QRscratch.QRgen==CC->usersupp.generation[a])
-                       )
+                       /* See if there is an existing user/room relationship */
+                       ra = CtdlRoomAccess(&QRscratch, &CC->usersupp);
        
-                       ) ok = 1;
-
-
-               if (ok==1) {
-
-                       if (  (QRscratch.QRflags&QR_PASSWORDED) &&
-                               (CC->usersupp.axlevel<6) &&
-                               (QRscratch.QRgen!=CC->usersupp.generation[a]) &&
-                               (strcasecmp(QRscratch.QRpasswd,password))
-                               ) {
-                                       cprintf("%d wrong or missing passwd\n",
-                                               ERROR+PASSWORD_REQUIRED);
+                       /* 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);
                                        return;
                                        }
-
-                       usergoto(a,1);
-                       return;
+                               }
                        }
-
                }
+       
        cprintf("%d room '%s' not found\n",ERROR+ROOM_NOT_FOUND,towhere);
        }
 
@@ -794,22 +776,10 @@ void cmd_whok(void) {
                bzero(&temp, sizeof(struct usersupp));
                memcpy(&temp, cdbus->ptr, cdbus->len);
                cdb_free(cdbus);
-               if ((CC->quickroom.QRflags & QR_INUSE)
-                       && ( (CC->curr_rm!=2) || (temp.axlevel>=6) )
-                       && (CC->quickroom.QRgen != (temp.forget[CC->curr_rm]) )
-
-                       && (    ((CC->quickroom.QRflags&QR_PREFONLY)==0)
-                       ||      (temp.axlevel>=5)
-                       )
-
-                       && (    ((CC->quickroom.QRflags&QR_PRIVATE)==0)
-                       ||      (temp.axlevel>=6)
-                       ||      (CC->quickroom.QRgen==(temp.generation[CC->curr_rm]))
-                       )
-
-                       && (strncmp(temp.fullname,"000",3))
 
-               ) cprintf("%s\n",temp.fullname);
+               if ( (CC->quickroom.QRflags & QR_INUSE)
+                       && (CtdlRoomAccess(&CC->quickroom, &temp) & UA_KNOWN)
+                  ) cprintf("%s\n",temp.fullname);
                }
        cprintf("000\n");
        }
@@ -1227,10 +1197,6 @@ unsigned create_room(int free_slot, char *new_room_name, int new_room_type, char
        /* be sure not to kick the creator out of the room! */
        lgetuser(&CC->usersupp,CC->curr_user);
        CtdlGetRelationship(&vbuf, &CC->usersupp, &qrbuf);
-       /* (old method) */
-       CC->usersupp.generation[free_slot] = qrbuf.QRgen;
-       CC->usersupp.forget[free_slot] = (-1);
-       /* (new method) */
        vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
        vbuf.v_flags = vbuf.v_flags | V_ACCESS;
        CtdlSetRelationship(&vbuf, &CC->usersupp, &qrbuf);
index 9bfc5bdd08f5ef3db0bbcd7efbcf790790bf9ae8..e1f06a6547ee7fa5e337a06308e4aaf7be10f639 100644 (file)
@@ -108,3 +108,54 @@ applicable for certain types of hooks).  The available user hook types are:
 
 #define EVT_PURGEUSER  100     /* Deleting a user */
 #define EVT_OUTPUTMSG  101     /* Outputting a message */
+
+
+   
+  FUNCTIONS WHICH MANIPULATE USER/ROOM RELATIONSHIPS
+
+ void CtdlGetRelationship(struct visit *vbuf,
+                        struct usersupp *rel_user,
+                        struct quickroom *rel_room);
+ void CtdlSetRelationship(struct visit *newvisit,
+                        struct usersupp *rel_user,
+                        struct quickroom *rel_room);
+ These functions get/set a "struct visit" structure which may contain
+information about the relationship between a user and a room.  Specifically:
+
+struct visit {
+        char v_roomname[20];
+        long v_generation;
+        long v_lastseen;
+        unsigned int v_flags;
+        };
+
+#define V_FORGET        1               /* User has zapped this room        */
+#define V_LOCKOUT       2               /* User is locked out of this room  */
+#define V_ACCESS        4               /* Access is granted to this room   */
+ Don't change v_roomname or v_generation; they're used to identify the room
+being referred to.  A room is unique to the system by its combination of room
+name and generation number.  If a new room is created with the same name as
+a recently deleted room, it will have a new generation number, and therefore
+stale "visit" records will not be applied (and will eventually be purged).
+ v_lastseen contains the number of the newest message the user has read in
+this room.  Any existing messages higher than this number can be considered
+as "new messages."
+ v_flags contains information regarding access to the room.
+  
+ int CtdlRoomAccess(struct quickroom *roombuf, struct usersupp *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
+contain:
+#define UA_INUSE                1      /* Room exists */
+#define UA_KNOWN                2      /* Room is in user's Known list */
+#define UA_GOTOALLOWED          4      /* User may <.G>oto this room */
+#define UA_HASNEWMSGS           8      /* Room contains new messages */
+#define UA_ZAPPED              16      /* User has forgotten this room */
index e9171ef23ab44b9ec5e407c4ea5e22d1dae5e74b..6a18dcf517968be82c0b4ee77ce38186522cc2fc 100644 (file)
@@ -297,9 +297,6 @@ void cmd_user(char *cmdbuf)
  * session startup code which is common to both cmd_pass() and cmd_newu()
  */
 void session_startup(void) {
-       int a;
-       struct quickroom qr;
-
        syslog(LOG_NOTICE,"user <%s> logged in",CC->curr_user);
 
        lgetuser(&CC->usersupp,CC->curr_user);
@@ -318,17 +315,6 @@ void session_startup(void) {
                CC->usersupp.axlevel = 6;
                }
 
- /******************************************************************************/
- /* FIX  It is safe to remove this segment during the cutover                  */
-       for (a=0; a<MAXROOMS; ++a) {
-               getroom(&qr,a);
-               if (CC->usersupp.generation[a] != qr.QRgen)
-                                       CC->usersupp.generation[a]=(-1);
-               if (CC->usersupp.forget[a] != qr.QRgen)
-                                       CC->usersupp.forget[a]=(-1);
-               }
- /******************************************************************************/
-
        lputuser(&CC->usersupp,CC->curr_user);
 
         /* Run any cleanup routines registered by loadable modules */
@@ -502,14 +488,6 @@ int create_user(char *newusername)
        strcpy(CC->usersupp.password,"");
        (CC->logged_in) = 1;
 
-       /********************************************************/
-       /* FIX this can safely be removed during the cutover... */
-       for (a=0; a<MAXROOMS; ++a) {
-               CC->usersupp.generation[a]=(-1);
-               CC->usersupp.forget[a]=(-1);
-               }
-       /********************************************************/
-
        /* These are the default flags on new accounts */
        CC->usersupp.flags =
                US_NEEDVALID|US_LASTOLD|US_DISAPPEAR|US_PAGINATOR|US_FLOORS;
@@ -700,10 +678,6 @@ void cmd_slrp(char *new_ptr)
 
        lgetuser(&CC->usersupp, CC->curr_user);
 
-       /* old method - remove */
-       CC->usersupp.lastseen[CC->curr_rm] = newlr;
-
-       /* new method */
        CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
        vbuf.v_lastseen = newlr;
        CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
@@ -754,21 +728,11 @@ void cmd_invt_kick(char *iuser, int op)
        CtdlGetRelationship(&vbuf, &USscratch, &CC->quickroom);
 
        if (op==1) {
-               /* old method -- FIX remove this when we're ready */
-               USscratch.generation[CC->curr_rm]=CC->quickroom.QRgen;
-               USscratch.forget[CC->curr_rm]=(-1);
-
-               /* new method */
                vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
                vbuf.v_flags = vbuf.v_flags | V_ACCESS;
                }
 
        if (op==0) {
-               /* old method -- FIX remove this when we're ready */
-               USscratch.generation[CC->curr_rm]=(-1);
-               USscratch.forget[CC->curr_rm]=CC->quickroom.QRgen;
-
-               /* new method */
                vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;
                vbuf.v_flags = vbuf.v_flags | V_FORGET | V_LOCKOUT;
                }
@@ -824,11 +788,6 @@ void cmd_forg(void) {
        lgetuser(&CC->usersupp,CC->curr_user);
        CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
 
-       /* old method -- FIX remove this when we're ready */
-       CC->usersupp.forget[CC->curr_rm] = CC->quickroom.QRgen;
-       CC->usersupp.generation[CC->curr_rm] = (-1);
-
-       /* new method */
        vbuf.v_flags = vbuf.v_flags | V_FORGET;
 
        CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
@@ -1351,8 +1310,10 @@ int NewMailCount() {
                num_mails = cdbmb->len / sizeof(long);
                mailbox = (long *) cdbmb->ptr;
                if (num_mails > 0) for (a=0; a<num_mails; ++a) {
-                       if (mailbox[a] > (CC->usersupp.lastseen[1]))
+                       /*
+                       if (message is new FIX FIX FIX)
                                ++num_newmsgs;
+                       */
                        }
                cdb_free(cdbmb);
                }