A little more with the API coding style.
[citadel.git] / citadel / room_ops.c
index f0c5cc98ea81f106f8bde29d7664df1457107ace..5c2dec0c3cd5e61a647bc7fb05a4208392d7fb58 100644 (file)
@@ -344,6 +344,62 @@ void CtdlPutRoomLock(struct ctdlroom *qrbuf)
 
 /****************************************************************************/
 
+
+/*
+ * CtdlGetFloorByName()  -  retrieve the number of the named floor
+ * return < 0 if not found else return floor number
+ */
+int CtdlGetFloorByName(const char *floor_name)
+{
+       int a;
+       struct floor *flbuf = NULL;
+
+       for (a = 0; a < MAXFLOORS; ++a) {
+               flbuf = CtdlGetCachedFloor(a);
+
+               /* check to see if it already exists */
+               if ((!strcasecmp(flbuf->f_name, floor_name))
+                   && (flbuf->f_flags & F_INUSE)) {
+                       return a;
+               }
+       }
+       return -1;
+}
+
+
+
+/*
+ * CtdlGetFloorByNameLock()  -  retrieve floor number for given floor and lock the floor list.
+ */
+int CtdlGetFloorByNameLock(const char *floor_name)
+{
+       begin_critical_section(S_FLOORTAB);
+       return CtdlGetFloorByName(floor_name);
+}
+
+
+
+/*
+ * CtdlGetAvailableFloor()  -  Return number of first unused floor
+ * return < 0 if none available
+ */
+int CtdlGetAvailableFloor(void)
+{
+       int a;
+       struct floor *flbuf = NULL;
+
+       for (a = 0; a < MAXFLOORS; a++) {
+               flbuf = CtdlGetCachedFloor(a);
+
+               /* check to see if it already exists */
+               if ((flbuf->f_flags & F_INUSE) == 0) {
+                       return a;
+               }
+       }
+       return -1;
+}
+
+
 /*
  * CtdlGetFloor()  -  retrieve floor data from disk
  */
@@ -438,10 +494,11 @@ void CtdlPutFloor(struct floor *flbuf, int floor_num)
 }
 
 
+
 /*
- * lputfloor()  -  same as CtdlPutFloor() but unlocks the record (if supported)
+ * CtdlPutFloorLock()  -  same as CtdlPutFloor() but unlocks the record (if supported)
  */
-void lputfloor(struct floor *flbuf, int floor_num)
+void CtdlPutFloorLock(struct floor *flbuf, int floor_num)
 {
 
        CtdlPutFloor(flbuf, floor_num);
@@ -450,6 +507,16 @@ void lputfloor(struct floor *flbuf, int floor_num)
 }
 
 
+
+/*
+ * lputfloor()  -  same as CtdlPutFloor() but unlocks the record (if supported)
+ */
+void lputfloor(struct floor *flbuf, int floor_num)
+{
+       CtdlPutFloorLock(flbuf, floor_num);
+}
+
+
 /* 
  *  Traverse the room file...
  */
@@ -1030,7 +1097,7 @@ void cmd_goto(char *gargs)
 
        /* Then try a mailbox name match */
        if (c != 0) {
-               MailboxName(augmented_roomname, sizeof augmented_roomname,
+               CtdlMailboxName(augmented_roomname, sizeof augmented_roomname,
                            &CC->user, towhere);
                c = CtdlGetRoom(&QRscratch, augmented_roomname);
                if (c == 0)
@@ -1512,7 +1579,7 @@ void cmd_geta(char *cmdbuf)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
-       if (getuserbynumber(&usbuf, CC->room.QRroomaide) == 0) {
+       if (CtdlGetUserByNumber(&usbuf, CC->room.QRroomaide) == 0) {
                cprintf("%d %s\n", CIT_OK, usbuf.fullname);
        } else {
                cprintf("%d \n", CIT_OK);
@@ -1795,7 +1862,7 @@ unsigned CtdlCreateRoom(char *new_room_name,
         * name accordingly (prepend the user number)
         */
        if (new_room_type == 4) {
-               MailboxName(qrbuf.QRname, sizeof qrbuf.QRname, &CC->user, new_room_name);
+               CtdlMailboxName(qrbuf.QRname, sizeof qrbuf.QRname, &CC->user, new_room_name);
        }
        else {
                safestrncpy(qrbuf.QRname, new_room_name, sizeof qrbuf.QRname);