Deleting rooms: Invalid pointers; safeguarrds
[citadel.git] / webcit / roomops.c
index b6fdaa8df8113f5154a3bddd45c2e60050fcb920..09534742eeaae5ba09b01b4222c68ef64487d60d 100644 (file)
@@ -1,21 +1,21 @@
 /*
  * Lots of different room-related operations.
  *
- * Copyright (c) 1996-2011 by the citadel.org team
+ * Copyright (c) 1996-2012 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
+ * modify it under the terms of the GNU General Public License, version 3.
+ * 
+ * 
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * 
+ * 
+ * 
  */
 
 #include "webcit.h"
@@ -354,20 +354,30 @@ void ParseGoto(folder *room, StrBuf *Line)
  */
 void delete_room(void)
 {
-       StrBuf *Line;
+       StrBuf *Line = NewStrBuf();
+       const StrBuf *GoBstr;
        
-       serv_puts("KILL 1");
-       StrBuf_ServGetln(Line);
-       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
-               display_main_menu();
-       } else {
-               StrBuf *Buf;
-               
-               FlushRoomlist ();
-               Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
-               smart_goto(Buf);
-               FreeStrBuf(&Buf);
+       GoBstr = sbstr("go");
+
+       if (GoBstr != NULL)
+       {
+               if (gotoroom(GoBstr) == 200)
+               {
+                       serv_puts("KILL 1");
+                       StrBuf_ServGetln(Line);
+                       if (GetServerStatusMsg(Line, NULL, 1, 2) == 2) {
+                               StrBuf *Buf;
+                               
+                               FlushRoomlist ();
+                               Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
+                               smart_goto(Buf);
+                               FreeStrBuf(&Buf);
+                               FreeStrBuf(&Line);
+                               return;
+                       }
+               }
        }
+       display_main_menu();
        FreeStrBuf(&Line);
 }
 
@@ -1038,6 +1048,9 @@ void netedit(void) {
        StrBuf *TmpBuf;
        int Done;
 
+        if (havebstr("force_room")) {
+                gotoroom(sbstr("force_room"));
+       }
        /*/ TODO: do line dynamic! */
        if (havebstr("line_pop3host")) {
                strcpy(line, bstr("prefix"));