]> code.citadel.org Git - citadel.git/blobdiff - citadel/citserver.c
* Cleaned up some things that generated compiler warnings
[citadel.git] / citadel / citserver.c
index 9afecf8cf0c9a5953073af706ae6e7a94cc03120..eda6a754efb9fd26597d5cbb0959fcf9e6dc8780 100644 (file)
@@ -91,10 +91,10 @@ void master_startup(void) {
        check_ref_counts();
 
        lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
-       create_room(BASEROOM,           0, "", 0, 1, 0);
-       create_room(AIDEROOM,           3, "", 0, 1, 0);
-       create_room(SYSCONFIGROOM,      3, "", 0, 1, 0);
-       create_room(config.c_twitroom,  0, "", 0, 1, 0);
+       create_room(BASEROOM,           0, "", 0, 1, 0, VIEW_BBS);
+       create_room(AIDEROOM,           3, "", 0, 1, 0, VIEW_BBS);
+       create_room(SYSCONFIGROOM,      3, "", 0, 1, 0, VIEW_BBS);
+       create_room(config.c_twitroom,  0, "", 0, 1, 0, VIEW_BBS);
 
        /* The "Local System Configuration" room doesn't need to be visible */
         if (lgetroom(&qrbuf, SYSCONFIGROOM) == 0) {
@@ -236,7 +236,7 @@ void RemoveContext (struct CitContext *con)
        logout(con);
 
        unlink(con->temp);
-       lprintf(CTDL_NOTICE, "Session %d: ended.\n", con->cs_pid);
+       lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
 
        /* Deallocate any user-data attached to this session */
        deallocate_user_data(con);
@@ -376,16 +376,16 @@ char CtdlCheckExpress(void) {
 void cmd_time(void)
 {
    time_t tv;
-   struct tm *tmp;
+   struct tm tmp;
    
    tv = time(NULL);
-   tmp = localtime(&tv);
+   localtime_r(&tv, &tmp);
    
    /* timezone and daylight global variables are not portable. */
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
-   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp->tm_gmtoff, tmp->tm_isdst);
+   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst);
 #else
-   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp->tm_isdst);
+   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst);
 #endif
 }
 
@@ -593,6 +593,8 @@ void cmd_emsg(char *mname)
        char *dirs[2];
        int a;
 
+       unbuffer_output();
+
        if (CtdlAccessCheck(ac_aide)) return;
 
        extract(buf,mname,0);
@@ -667,6 +669,11 @@ int CtdlAccessCheck(int required_level) {
                return(-1);
        }
 
+       if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
+               cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
+               return(-1);
+       }
+
        if (CC->user.axlevel >= 6) return(0);
        if (required_level >= ac_aide) {
                cprintf("%d This command requires Aide access.\n",
@@ -681,12 +688,6 @@ int CtdlAccessCheck(int required_level) {
                return(-1);
        }
 
-       if (CC->logged_in) return(0);
-       if (required_level >= ac_logged_in) {
-               cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
-               return(-1);
-       }
-
        /* shhh ... succeed quietly */
        return(0);
 }
@@ -864,7 +865,7 @@ void generate_nonce(struct CitContext *con) {
  */
 void begin_session(struct CitContext *con)
 {
-       int len;        /* should be socklen_t but doesn't work on Macintosh */
+       int len;
        struct sockaddr_in sin;
 
        /* 
@@ -893,7 +894,7 @@ void begin_session(struct CitContext *con)
        len = sizeof sin;
        if (!CC->is_local_socket) {
                if (!getpeername(con->client_socket,
-                  (struct sockaddr *) &sin, &len))
+                  (struct sockaddr *) &sin, &len))     /* should be socklen_t but doesn't work on Macintosh */
                        locate_host(con->cs_host, sizeof con->cs_host,
                                con->cs_addr, sizeof con->cs_addr,
                                &sin.sin_addr);
@@ -948,6 +949,8 @@ void do_command_loop(void) {
        }
        lprintf(CTDL_INFO, "Citadel: %s\n", cmdbuf);
 
+       buffer_output();
+
        /*
         * Let other clients see the last command we executed, and
         * update the idle time, but not NOOP, QNOP, PEXP, or GEXP.
@@ -1316,6 +1319,8 @@ void do_command_loop(void) {
                        ERROR + CMD_NOT_SUPPORTED);
               }
 
+       unbuffer_output();
+
        /* Run any after-each-command routines registered by modules */
        PerformSessionHooks(EVT_CMD);
 }