]> code.citadel.org Git - citadel.git/blobdiff - citadel/citadel.c
centralized filename calculation
[citadel.git] / citadel / citadel.c
index b08346f9369085f8adc695f798decd6c0cbd3d49..6779f8978c8b825a245f87a9eb02d22839be2f53 100644 (file)
@@ -50,6 +50,7 @@
 #include "snprintf.h"
 #endif
 #include "screen.h"
+#include "citadel_dirs.h"
 
 #include "md5.h"
 
@@ -147,7 +148,7 @@ void ctdl_logoff(char *file, int line, CtdlIPC *ipc, int code)
                kill(0 - getpgrp(), SIGKILL);
        }
        color(ORIGINAL_PAIR);   /* Restore the old color settings */
-       sttybbs(SB_RESTORE);    /* return the old terminal settings */
+       stty_ctdl(SB_RESTORE);  /* return the old terminal settings */
        /* 
         * uncomment the following if you need to know why Citadel exited
        printf("*** Exit code %d at %s:%d\n", code, file, line);
@@ -174,7 +175,7 @@ void dropcarr(int signum)
  */
 void catch_sigcont(int signum)
 {
-       sttybbs(SB_LAST);
+       stty_ctdl(SB_LAST);
        signal(SIGCONT, catch_sigcont);
 }
 
@@ -211,7 +212,7 @@ void userlist(CtdlIPC *ipc, char *patn)
        int r;                          /* IPC response code */
        char *listing = NULL;
 
-       r = CtdlIPCUserListing(ipc, &listing, buf);
+       r = CtdlIPCUserListing(ipc, patn, &listing, buf);
        if (r / 100 != 1) {
                pprintf("%s\n", buf);
                return;
@@ -219,12 +220,12 @@ void userlist(CtdlIPC *ipc, char *patn)
 
        pprintf("       User Name           Num  L  LastCall  Calls Posts\n");
        pprintf("------------------------- ----- - ---------- ----- -----\n");
-       while (strlen(listing) > 0) {
-               extract_token(buf, listing, 0, '\n');
+       if (listing != NULL) while (strlen(listing) > 0) {
+               extract_token(buf, listing, 0, '\n', sizeof buf);
                remove_token(listing, 0, '\n');
 
                if (sigcaught == 0) {
-                   extract(fl, buf, 0);
+                   extract_token(fl, buf, 0, '|', sizeof fl);
                    if (pattern(fl, patn) >= 0) {
                        pprintf("%-25s ", fl);
                        pprintf("%5ld %d ", extract_long(buf, 2),
@@ -250,7 +251,7 @@ void userlist(CtdlIPC *ipc, char *patn)
  */
 void load_user_info(char *params)
 {
-       extract(fullname, params, 0);
+       extract_token(fullname, params, 0, '|', sizeof fullname);
        axlevel = extract_int(params, 1);
        timescalled = extract_int(params, 2);
        posted = extract_int(params, 3);
@@ -484,7 +485,7 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
                        system(rc_gotmail_cmd);
                }
        }
-       status_line(ipc->ServInfo.humannode, ipc->ServInfo.bbs_city,
+       status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location,
                        room_name, secure, newmailcount);
 }
 
@@ -848,7 +849,7 @@ char *SortOnlineUsers(char *listing) {
        /* Copy the list into a fixed-record-size array for sorting */
        for (i=0; i<rows; ++i) {
                memset(buf, 0, SIZ);
-               extract_token(buf, listing, i, '\n');
+               extract_token(buf, listing, i, '\n', sizeof buf);
                memcpy(&sortbuf[i*SIZ], buf, (size_t)SIZ);
        }
 
@@ -900,14 +901,14 @@ void who_is_online(CtdlIPC *ipc, int longlist)
                        int isidle = 0;
                        
                        /* Get another line */
-                       extract_token(buf, listing, 0, '\n');
+                       extract_token(buf, listing, 0, '\n', sizeof buf);
                        remove_token(listing, 0, '\n');
 
-                       extract(username, buf, 1);
-                       extract(roomname, buf, 2);
-                       extract(fromhost, buf, 3);
-                       extract(clientsoft, buf, 4);
-                       extract(flags, buf, 7);
+                       extract_token(username, buf, 1, '|', sizeof username);
+                       extract_token(roomname, buf, 2, '|', sizeof roomname);
+                       extract_token(fromhost, buf, 3, '|', sizeof fromhost);
+                       extract_token(clientsoft, buf, 4, '|', sizeof clientsoft);
+                       extract_token(flags, buf, 7, '|', sizeof flags);
 
                        idletime = timenow - extract_long(buf, 5);
                        idlehours = idletime / 3600;
@@ -926,9 +927,9 @@ void who_is_online(CtdlIPC *ipc, int longlist)
                        }
 
                        if (longlist) {
-                               extract(actual_user, buf, 8);
-                               extract(actual_room, buf, 9);
-                               extract(actual_host, buf, 10);
+                               extract_token(actual_user, buf, 8, '|', sizeof actual_user);
+                               extract_token(actual_room, buf, 9, '|', sizeof actual_room);
+                               extract_token(actual_host, buf, 10, '|', sizeof actual_host);
 
                                pprintf("  Flags: %s\n", flags);
                                pprintf("Session: %d\n", extract_int(buf, 0));
@@ -1054,9 +1055,9 @@ int main(int argc, char **argv)
                logoff(NULL, 3);
        }
 
-       sttybbs(SB_SAVE);       /* Store the old terminal parameters */
+       stty_ctdl(SB_SAVE);     /* Store the old terminal parameters */
        load_command_set();     /* parse the citadel.rc file */
-       sttybbs(SB_NO_INTR);    /* Install the new ones */
+       stty_ctdl(SB_NO_INTR);  /* Install the new ones */
        /* signal(SIGHUP, dropcarr);FIXME */    /* Cleanup gracefully if carrier is dropped */
        signal(SIGPIPE, dropcarr);      /* Cleanup gracefully if local conn. dropped */
        signal(SIGTERM, dropcarr);      /* Cleanup gracefully if terminated */
@@ -1111,8 +1112,8 @@ int main(int argc, char **argv)
                if (!strcmp(argv[a], "-p")) {
                        struct stat st;
                
-                       if (chdir(BBSDIR) < 0) {
-                               perror("can't change to " BBSDIR);
+                       if (chdir(CTDLDIR) < 0) {
+                               perror("can't change to " CTDLDIR);
                                logoff(NULL, 3);
                        }
 
@@ -1122,7 +1123,7 @@ int main(int argc, char **argv)
                         * guaranteed to have the uid/gid we want.
                         */
                        if (!getuid() || !getgid()) {
-                               if (stat(BBSDIR "/citadel.config", &st) < 0) {
+                               if (stat(file_citadel_config, &st) < 0) {
                                        perror("couldn't stat citadel.config");
                                        logoff(NULL, 3);
                                }
@@ -1203,10 +1204,10 @@ int main(int argc, char **argv)
 
        get_serv_info(ipc, telnet_client_host);
        scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode,
-                  ipc->ServInfo.bbs_city);
+                  ipc->ServInfo.site_location);
        scr_flush();
 
-       status_line(ipc->ServInfo.humannode, ipc->ServInfo.bbs_city, NULL,
+       status_line(ipc->ServInfo.humannode, ipc->ServInfo.site_location, NULL,
                    secure, -1);
 
        screenwidth = 80;       /* default screen dimensions */
@@ -1358,9 +1359,9 @@ NEWUSR:   if (strlen(rc_password) == 0) {
         * program.  Don't mess with these once they've been set, because we
         * will be unlinking them later on in the program and we don't
         * want to delete something that we didn't create. */
-       snprintf(temp, sizeof temp, tmpnam(NULL));
-       snprintf(temp2, sizeof temp2, tmpnam(NULL));
-       snprintf(tempdir, sizeof tempdir, tmpnam(NULL));
+       CtdlMakeTempFileName(temp, sizeof temp);
+       CtdlMakeTempFileName(temp2, sizeof temp2);
+       CtdlMakeTempFileName(tempdir, sizeof tempdir);
 
        /* Get screen dimensions.  First we go to a default of 80x24.  Then
         * we try to get the user's actual screen dimensions off the server.
@@ -1410,7 +1411,7 @@ NEWUSR:   if (strlen(rc_password) == 0) {
                                formout(ipc, "help");
                                break;
                        case 4:
-                               entmsg(ipc, 0, 0);
+                               entmsg(ipc, 0, ((userflags & US_EXTEDIT) ? 2 : 0));
                                break;
                        case 36:
                                entmsg(ipc, 0, 1);
@@ -1422,7 +1423,9 @@ NEWUSR:   if (strlen(rc_password) == 0) {
                                {
                                        /* Only m.author is used */
                                        struct ctdlipcmessage m;
-                                       newprompt("What do you want your username to be? ", m.author, USERNAME_SIZE - 1);
+                                       newprompt("What do you want your username to be? ",
+                                               m.author, USERNAME_SIZE - 1);
+                                       m.text = "";
                                        r = CtdlIPCPostMessage(ipc, 2, &m, aaa);
                                        if (r / 100 != 2)
                                                scr_printf("%s\n", aaa);
@@ -1695,12 +1698,12 @@ NEWUSR: if (strlen(rc_password) == 0) {
                        case 2:
                                if (ipc->isLocal) {
                                        screen_reset();
-                                       sttybbs(SB_RESTORE);
+                                       stty_ctdl(SB_RESTORE);
                                        snprintf(aaa, sizeof aaa, "USERNAME=\042%s\042; export USERNAME;"
                                                 "exec ./subsystem %ld %d %d", fullname,
                                                 usernum, screenwidth, axlevel);
                                        ka_system(aaa);
-                                       sttybbs(SB_NO_INTR);
+                                       stty_ctdl(SB_NO_INTR);
                                        screen_set();
                                } else {
                                        scr_printf("*** Can't run doors when server is not local.\n");
@@ -1859,7 +1862,7 @@ TERMN8:   scr_printf("%s logged out.", fullname);
        CtdlIPCLogout(ipc);
        if ((mcmd == 29) || (mcmd == 15)) {
                screen_delete();
-               sttybbs(SB_RESTORE);
+               stty_ctdl(SB_RESTORE);
                formout(ipc, "goodbye");
                logoff(ipc, 0);
        }