* Misc. routines converted to new IPC code
authorMichael Hampton <io_error@uncensored.citadel.org>
Mon, 1 Jul 2002 14:20:50 +0000 (14:20 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Mon, 1 Jul 2002 14:20:50 +0000 (14:20 +0000)
citadel/citadel.c
citadel/citadel_ipc.c
citadel/commands.c
citadel/messages.c
citadel/routines.c
citadel/routines2.c
citadel/serv_info.c [deleted file]
citadel/serv_info.h [deleted file]

index 93668df856664e640162353e4a57ca398399505b..e2ba5614c2841b582834184ffcd4189ada3f93b8 100644 (file)
@@ -515,6 +515,8 @@ void forget_all_rooms_on(int ffloor)
 {
        char buf[SIZ];
        struct march *flist, *fptr;
+       struct ctdlipcroom *roomrec;    /* Ignored */
+       int r;                          /* IPC response code */
 
        scr_printf("Forgetting all rooms on %s...\r", &floorlist[ffloor][0]);
        scr_flush();
@@ -533,12 +535,9 @@ void forget_all_rooms_on(int ffloor)
                extract(fptr->march_name, buf, 0);
        }
        while (flist != NULL) {
-               snprintf(buf, sizeof buf, "GOTO %s", flist->march_name);
-               serv_puts(buf);
-               serv_gets(buf);
-               if (buf[0] == '2') {
-                       serv_puts("FORG");
-                       serv_gets(buf);
+               r = CtdlIPCGotoRoom(flist->march_name, "", &roomrec, buf);
+               if (r / 100 == 2) {
+                       r = CtdlIPCForgetRoom(buf);
                }
                fptr = flist;
                flist = flist->next;
index 986add022a197e243ec3ea1ab95922bac927d981..6538ac06ffdc11ed679d86a5dea76e284a31e4ef 100644 (file)
@@ -151,9 +151,12 @@ int CtdlIPCTryPassword(const char *passwd, char *cret)
 
 /*
  * Create a new user.  This returns 200 plus the same arguments as TryPassword
- * unless there was a problem creating the account.
+ * if selfservice is nonzero, unless there was a problem creating the account.
+ * If selfservice is zero, creates a new user but does not log out the existing
+ * user - intended for use by system administrators to create accounts on
+ * behalf of other users.
  */
-int CtdlIPCCreateUser(const char *username, char *cret)
+int CtdlIPCCreateUser(const char *username, int selfservice, char *cret)
 {
        register int ret;
        char *aaa;
@@ -164,7 +167,7 @@ int CtdlIPCCreateUser(const char *username, char *cret)
        aaa = (char *)malloc(strlen(username) + 6);
        if (!aaa) return -1;
 
-       sprintf(aaa, "NEWU %s", username);
+       sprintf(aaa, "%s %s", selfservice ? "NEWU" : "CREU",  username);
        ret = CtdlIPCGenericCommand(aaa, NULL, 0, NULL, NULL, cret);
        free(aaa);
        return ret;
@@ -1502,19 +1505,21 @@ time_t CtdlIPCServerTime(char *cret)
 
 
 /* AGUP */
-int CtdlIPCAideGetUserParameters(struct usersupp **uret, char *cret)
+int CtdlIPCAideGetUserParameters(const char *who,
+                                struct usersupp **uret, char *cret)
 {
        register int ret;
        char *aaa;
 
        if (!cret) return -2;
        if (!uret) return -2;
-       if (!*uret) return -2;
+       if (!*uret) *uret = (struct usersupp *)calloc(1, sizeof(struct usersupp));
+       if (!*uret) return -1;
 
        aaa = (char *)malloc(strlen(uret[0]->fullname) + 6);
        if (!aaa) return -1;
 
-       sprintf(aaa, "AGUP %s", uret[0]->fullname);
+       sprintf(aaa, "AGUP %s", who);
        ret = CtdlIPCGenericCommand(aaa, NULL, 0, NULL, NULL, cret);
        if (ret / 100 == 2) {
                extract(uret[0]->fullname, cret, 0);
@@ -1658,6 +1663,22 @@ int CtdlIPCStartEncryption(char *cret)
 }
 
 
+/* QDIR */
+int CtdlIPCDirectoryLookup(const char *address, char *cret)
+{
+       char *aaa;
+
+       if (!address) return -2;
+       if (!cret) return -2;
+
+       aaa = (char *)malloc(strlen(address) + 6);
+       if (!aaa) return -1;
+
+       sprintf(aaa, "QDIR %s", address);
+       return CtdlIPCGenericCommand(aaa, NULL, 0, NULL, NULL, cret);
+}
+
+
 /*
  * Not implemented:
  * 
@@ -1723,12 +1744,12 @@ int CtdlIPCSendListing(const char *listing)
 {
        char *text;
 
-       text = (char *)malloc(strlen(listing) + 5);
+       text = (char *)malloc(strlen(listing) + 6);
        if (text) {
                strcpy(text, listing);
-               if (text[strlen(text) - 1] == '\n')
+               while (text[strlen(text) - 1] == '\n')
                        text[strlen(text) - 1] = '\0';
-               strcat(text, "000");
+               strcat(text, "\n000");
                serv_puts(text);
                free(text);
                text = NULL;
index cdb04f9e8cee9e6873e61a032edeab983ad4c0e3..2208a3ba45a3a517e85a4853e2fd1af2e1cee3e0 100644 (file)
@@ -345,7 +345,6 @@ void set_keepalives(int s)
 
 static time_t idlet = 0;
 static void really_do_keepalive(void) {
-       char buf[1024];
        int r;                          /* IPC response code */
 
        time(&idlet);
@@ -646,7 +645,7 @@ int boolprompt(char *prompt, int prev_val)
        color(DIM_WHITE);
        scr_printf("%s ", prompt);
        color(DIM_MAGENTA);
-       scr_printf(" [");
+       scr_printf("[");
        color(BRIGHT_MAGENTA);
        scr_printf("%s", (prev_val ? "Yes" : "No"));
        color(DIM_MAGENTA);
index f1b6e1e74862dc1cf57ac39c9aec13a5a2e7ab57..b2d9da93d1f5285df5a4ed593ab0b9371cfa631e 100644 (file)
@@ -90,10 +90,10 @@ extern int editor_pid;
 void ka_sigcatch(int signum)
 {
        char buf[SIZ];
+
        alarm(S_KEEPALIVE);
        signal(SIGALRM, ka_sigcatch);
-       serv_puts("NOOP");
-       serv_gets(buf);
+       CtdlIPCNoop();
 }
 
 
@@ -1180,6 +1180,7 @@ void readmsgs(
        char targ[ROOMNAMELEN];
        char filename[SIZ];
        FILE *dest = NULL;      /* Alternate destination other than screen */
+       int r;                          /* IPC response code */
 
        if (c < 0)
                b = (MAXMSGS - 1);
@@ -1296,9 +1297,7 @@ RMSGREAD: scr_flush();
                if (rc_alt_semantics && c == 1) {
                        char buf[SIZ];
 
-                       snprintf(buf, sizeof(buf), "SEEN %ld", msg_arr[a]);
-                       serv_puts(buf);
-                       serv_gets(buf); /* Don't need to check this? */
+                       r = CtdlIPCSetMessageSeen(msg_arr[a], 1, buf);
                }
                if (e == 3)
                        return;
@@ -1458,19 +1457,16 @@ RMSGREAD:       scr_flush();
                        newprompt("Enter target room: ",
                                  targ, ROOMNAMELEN - 1);
                        if (strlen(targ) > 0) {
-                               snprintf(cmd, sizeof cmd, "MOVE %ld|%s|%d",
-                                       msg_arr[a], targ,
-                                       (e == 'c' ? 1 : 0));
-                               serv_puts(cmd);
-                               serv_gets(cmd);
-                               scr_printf("%s\n", &cmd[4]);
-                               if (cmd[0] == '2')
+                               r = CtdlIPCMoveMessage((e == 'c' ? 1 : 0),
+                                                      msg_arr[a], targ, cmd);
+                               scr_printf("%s\n", cmd);
+                               if (r / 100 == 2)
                                        msg_arr[a] = 0L;
                        } else {
                                goto RMSGREAD;
                        }
-                       if (cmd[0] != '2')
-                               goto RMSGREAD;
+                       if (r / 100 != 2)       /* r will be init'ed, FIXME */
+                               goto RMSGREAD;  /* the logic here sucks */
                        break;
                case 'f':
                        newprompt("Which section? ", filename,
@@ -1491,11 +1487,9 @@ RMSGREAD:        scr_flush();
                case 'd':
                        scr_printf("*** Delete this message? ");
                        if (yesno() == 1) {
-                               snprintf(cmd, sizeof cmd, "DELE %ld", msg_arr[a]);
-                               serv_puts(cmd);
-                               serv_gets(cmd);
-                               scr_printf("%s\n", &cmd[4]);
-                               if (cmd[0] == '2')
+                               r = CtdlIPCDeleteMessage(msg_arr[a], cmd);
+                               scr_printf("%s\n", cmd);
+                               if (r / 100 == 2)
                                        msg_arr[a] = 0L;
                        } else {
                                goto RMSGREAD;
index d765c0c49bc3523f4d637eb348008a39c9807221..b86493d298895d6735dcbe27c8995ea94efc2481 100644 (file)
@@ -38,6 +38,8 @@
 #ifdef HAVE_UTMPX_H
 #include <utmpx.h>
 #endif
+#include "citadel.h"
+#include "citadel_ipc.h"
 #include "screen.h"
 
 #ifndef HAVE_GETUTLINE
@@ -104,75 +106,52 @@ void hit_any_key(void) {          /* hit any key to continue */
 void edituser(void)
 {
        char buf[SIZ];
-       char who[SIZ];
-       char pass[SIZ];
-       int flags;
-       int timescalled;
-       int posted;
-       int axlevel;
-       long usernum;
-       time_t lastcall;
-       int userpurge;
+       char who[USERNAME_SIZE];
+       struct usersupp *user = NULL;
        int newnow = 0;
+       int r;                          /* IPC response code */
 
-       newprompt("User name: ",who,25);
-AGUP:  snprintf(buf, sizeof buf, "AGUP %s",who);
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0]!='2') {
-               scr_printf("%s\n",&buf[4]);
+       newprompt("User name: ", who, 25);
+       while ((r = CtdlIPCAideGetUserParameters(who, &user, buf)) / 100 != 2) {
+               scr_printf("%s\n", buf);
                scr_printf("Do you want to create this user? ");
                if (yesno()) {
-                       snprintf(buf, sizeof buf, "CREU %s", who);
-                       serv_puts(buf);
-                       serv_gets(buf);
-                       if (buf[0] == '2') {
+                       r = CtdlIPCCreateUser(who, 0, buf);
+                       if (r / 100 == 2) {
                                newnow = 1;
-                               goto AGUP;
+                               continue;
                        }
                        scr_printf("%s\n",&buf[4]);
-                       return;
                }
+               free(user);
                return;
        }
-       extract(who, &buf[4], 0);
-       extract(pass, &buf[4], 1);
-       flags = extract_int(&buf[4], 2);
-       timescalled = extract_int(&buf[4], 3);
-       posted = extract_int(&buf[4], 4);
-       axlevel = extract_int(&buf[4], 5);
-       usernum = extract_long(&buf[4], 6);
-       lastcall = extract_long(&buf[4], 7);
-       userpurge = extract_int(&buf[4], 8);
-
-       val_user(who, 0); /* Display registration */
-
-       if (newnow) {
-               newprompt("Password: ", pass, -19);
-       }
-       else if (boolprompt("Change password", 0)) {
-               strprompt("Password", pass, -19);
+
+       val_user(user->fullname, 0); /* Display registration */
+
+       if (newnow || boolprompt("Change password", 0)) {       /* I'm lazy */
+               strprompt("Password", user->password, -19);
        }
 
-       axlevel = intprompt("Access level", axlevel, 0, 6);
-       if (boolprompt("Ask user to register again", !(flags & US_REGIS)))
-               flags &= ~US_REGIS;
+       user->axlevel = intprompt("Access level", user->axlevel, 0, 6);
+       if (boolprompt("Ask user to register again", !(user->flags & US_REGIS)))
+               user->flags &= ~US_REGIS;
        else
-               flags |= US_REGIS;
-       timescalled = intprompt("Times called", timescalled, 0, INT_MAX);
-       posted = intprompt("Messages posted", posted, 0, INT_MAX);
-       lastcall = (boolprompt("Set last call to now", 0)?time(NULL):lastcall);
-       userpurge = intprompt("Purge time (in days, 0 for system default",
-                               userpurge, 0, INT_MAX);
-
-       snprintf(buf, sizeof buf, "ASUP %s|%s|%d|%d|%d|%d|%ld|%ld|%d",
-               who, pass, flags, timescalled, posted, axlevel, usernum,
-               (long)lastcall, userpurge);
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0]!='2') {
-               scr_printf("%s\n",&buf[4]);
+               user->flags |= US_REGIS;
+       user->timescalled = intprompt("Times called",
+                                     user->timescalled, 0, INT_MAX);
+       user->posted = intprompt("Messages posted",
+                                user->posted, 0, INT_MAX);
+       user->lastcall = boolprompt("Set last call to now", 0) ?
+                                               time(NULL) : user->lastcall;
+       user->USuserpurge = intprompt("Purge time (in days, 0 for system default",
+                                     user->USuserpurge, 0, INT_MAX);
+
+       r = CtdlIPCAideSetUserParameters(user, buf);
+       if (r / 100 != 2) {
+               scr_printf("%s\n", buf);
        }
+       free(user);
 }
 
 
@@ -219,112 +198,96 @@ int set_attr(int sval, char *prompt, unsigned int sbit, int backwards)
  */
 void enter_config(int mode)
 {
-       int width, height, flags, filter;
-       char buf[128];
+       char buf[SIZ];
+       struct usersupp *user = NULL;
+       int r;                          /* IPC response code */
 
-       snprintf(buf, sizeof buf, "GETU");
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0]!='2') {
-               scr_printf("%s\n",&buf[4]);
+       r = CtdlIPCGetConfig(&user, buf);
+       if (r / 100 != 2) {
+               scr_printf("%s\n", buf);
+               free(user);
                return;
        }
 
-       width = extract_int(&buf[4],0);
-       height = extract_int(&buf[4],1);
-       flags = extract_int(&buf[4],2);
-       filter = extract_int(&buf[4],3);
-
-       if ((mode==0)||(mode==1)) {
+       if (mode == 0 || mode == 1) {
 
-        width = intprompt("Enter your screen width",width,20,255);
-        height = intprompt("Enter your screen height",height,3,255);
+               user->USscreenwidth = intprompt("Enter your screen width",
+                                               user->USscreenwidth, 20, 255);
+               user->USscreenheight = intprompt("Enter your screen height",
+                                                user->USscreenheight, 3, 255);
  
-        flags = set_attr(flags,
-               "Are you an experienced Citadel user",
-               US_EXPERT,
-               0);
-        if ( ((flags&US_EXPERT)==0) && (mode==1)) {
-               return;
-        }
-        flags = set_attr(flags,
-               "Print last old message on New message request",
-               US_LASTOLD,
-               0);
-
-        flags = set_attr(flags,
-               "Prompt after each message",
-               US_NOPROMPT,
-               1);
-
-        if ((flags & US_NOPROMPT)==0)
-           flags = set_attr(flags,
-               "Use 'disappearing' prompts",
-               US_DISAPPEAR,
-               0);
-
-        flags = set_attr(flags,
-               "Pause after each screenful of text",
-               US_PAGINATOR,
-               0);
-
-        if ( (rc_prompt_control == 3) && (flags & US_PAGINATOR) ) {
-               flags = set_attr(flags,
-                       "<N>ext and <S>top work at paginator prompt",
-                       US_PROMPTCTL,
-                       0);
-        }
-
-        if (rc_floor_mode == RC_DEFAULT) {
-         flags = set_attr(flags,
-               "View rooms by floor",
-               US_FLOORS,
-               0);
-         }
-
-        if (rc_ansi_color == 3) {
-         flags = set_attr(flags,
-               "Enable color support",
-               US_COLOR,
-               0);
-         }
-       
-
-         if ((flags&US_EXPERT)==0) formout("unlisted");
-         flags = set_attr(flags,
-               "Be unlisted in userlog",
-               US_UNLISTED,
-               0);
-
-        }
-
-       if (mode==2) {
-        if (flags & US_EXPERT) {
-               flags = (flags ^ US_EXPERT);
-               scr_printf("Expert mode now OFF\n");
-               }
-        else {
-               flags = (flags | US_EXPERT);
-               scr_printf("Expert mode now ON\n");
+               user->flags = set_attr(user->flags,
+                                      "Are you an experienced Citadel user",
+                                      US_EXPERT, 0);
+               if ((user->flags & US_EXPERT) == 0 && mode == 1) {
+                       free(user);
+                       return;
                }
-        }
 
-       if (mode==3) {
-        if (flags & US_FLOORS) {
-               flags = (flags ^ US_FLOORS);
-               scr_printf("Floor mode now OFF\n");
+               user->flags = set_attr(user->flags,
+                       "Print last old message on New message request",
+                       US_LASTOLD, 0);
+
+               user->flags = set_attr(user->flags,
+                                      "Prompt after each message",
+                                      US_NOPROMPT, 1);
+
+               if ((user->flags & US_NOPROMPT) == 0)
+                       user->flags = set_attr(user->flags,
+                                              "Use 'disappearing' prompts",
+                                              US_DISAPPEAR, 0);
+
+               user->flags = set_attr(user->flags,
+                                      "Pause after each screenful of text",
+                                      US_PAGINATOR, 0);
+
+               if (rc_prompt_control == 3 && (user->flags & US_PAGINATOR))
+                       user->flags = set_attr(user->flags,
+                               "<N>ext and <S>top work at paginator prompt",
+                               US_PROMPTCTL, 0);
+
+               if (rc_floor_mode == RC_DEFAULT)
+                       user->flags = set_attr(user->flags,
+                                              "View rooms by floor",
+                                              US_FLOORS, 0);
+
+               if (rc_ansi_color == 3)
+                       user->flags = set_attr(user->flags,
+                                              "Enable color support",
+                                              US_COLOR, 0);
+
+               if ((user->flags & US_EXPERT) == 0)
+                       formout("unlisted");
+
+               user->flags = set_attr(user->flags,
+                                      "Be unlisted in userlog",
+                                      US_UNLISTED, 0);
+       }
+
+       if (mode == 2) {
+               if (user->flags & US_EXPERT) {
+                       user->flags ^= US_EXPERT;
+                       scr_printf("Expert mode now OFF\n");
+               } else {
+                       user->flags |= US_EXPERT;
+                       scr_printf("Expert mode now ON\n");
                }
-        else {
-               flags = (flags | US_FLOORS);
-               scr_printf("Floor mode now ON\n");
+       }
+
+       if (mode == 3) {
+               if (user->flags & US_FLOORS) {
+                       user->flags ^= US_FLOORS;
+                       scr_printf("Floor mode now OFF\n");
+               } else {
+                       user->flags |= US_FLOORS;
+                       scr_printf("Floor mode now ON\n");
                }
-        }
+       }
 
-       snprintf(buf, sizeof buf, "SETU %d|%d|%d|%d",width,height,flags,filter);
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0]!='2') scr_printf("%s\n",&buf[4]);
-       userflags = flags;
+       r = CtdlIPCSetConfig(user, buf);
+       if (r / 100 != 2) scr_printf("%s\n", buf);
+       userflags = user->flags;
+       free(user);
 }
 
 /*
index 50d7cfbb206e4d85f7ec6f66803c84b3392ea99a..8d10f9ed33d1586cca885493fe346856edb5f4a4 100644 (file)
@@ -38,6 +38,7 @@
 #include "routines.h"
 #include "commands.h"
 #include "tools.h"
+#include "citadel_ipc.h"
 #include "messages.h"
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
@@ -95,8 +96,9 @@ void entregis(void)
        char diruser[SIZ];
        char dirnode[SIZ];
        char holdemail[SIZ];
-       int a;
+       char *reg = NULL;
        int ok = 0;
+       int r;                          /* IPC response code */
 
        strcpy(tmpname, "");
        strcpy(tmpaddr, "");
@@ -107,26 +109,30 @@ void entregis(void)
        strcpy(tmpemail, "");
        strcpy(tmpcountry, "");
 
-       serv_puts("GREG _SELF_");
-       serv_gets(buf);
-       if (buf[0] == '1') {
-               a = 0;
-               while (serv_gets(buf), strcmp(buf, "000")) {
+       r = CtdlIPCGetUserRegistration(NULL, &reg, buf);
+       if (r / 100 == 1) {
+               int a = 0;
+
+               while (reg && strlen(reg) > 0) {
+
+                       extract_token(buf, reg, 0, '\n');
+                       remove_token(reg, 0, '\n');
+
                        if (a == 2)
                                strcpy(tmpname, buf);
-                       if (a == 3)
+                       else if (a == 3)
                                strcpy(tmpaddr, buf);
-                       if (a == 4)
+                       else if (a == 4)
                                strcpy(tmpcity, buf);
-                       if (a == 5)
+                       else if (a == 5)
                                strcpy(tmpstate, buf);
-                       if (a == 6)
+                       else if (a == 6)
                                strcpy(tmpzip, buf);
-                       if (a == 7)
+                       else if (a == 7)
                                strcpy(tmpphone, buf);
-                       if (a == 9)
+                       else if (a == 9)
                                strcpy(tmpemail, buf);
-                       if (a == 10)
+                       else if (a == 10)
                                strcpy(tmpcountry, buf);
                        ++a;
                }
@@ -143,12 +149,10 @@ void entregis(void)
                ok = 1;
                strcpy(holdemail, tmpemail);
                strprompt("Email address", tmpemail, 31);
-               snprintf(buf, sizeof buf, "QDIR %s", tmpemail);
-               serv_puts(buf);
-               serv_gets(buf);
-               if (buf[0]=='2') {
-                       extract_token(diruser, &buf[4], 0, '@');
-                       extract_token(dirnode, &buf[4], 1, '@');
+               r = CtdlIPCDirectoryLookup(tmpemail, buf);
+               if (r / 100 == 2) {
+                       extract_token(diruser, buf, 0, '@');
+                       extract_token(dirnode, buf, 1, '@');
                        striplt(diruser);
                        striplt(dirnode);
                        if ((strcasecmp(diruser, fullname))
@@ -166,43 +170,36 @@ void entregis(void)
        } while (ok == 0);
 
        /* now send the registration info back to the server */
-       serv_puts("REGI");
-       serv_gets(buf);
-       if (buf[0] != '4') {
-               scr_printf("%s\n", &buf[4]);
-               return;
+       reg = (char *)realloc(reg, 4096);       /* Overkill? */
+       if (reg) {
+               sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
+                       tmpname, tmpaddr, tmpcity, tmpstate,
+                       tmpzip, tmpphone, tmpemail, tmpcountry);
+               r = CtdlIPCSetRegistration(reg, buf);
+               if (r / 100 != 4)
+                       scr_printf("%s\n", buf);
+               free(reg);
        }
-       serv_puts(tmpname);
-       serv_puts(tmpaddr);
-       serv_puts(tmpcity);
-       serv_puts(tmpstate);
-       serv_puts(tmpzip);
-       serv_puts(tmpphone);
-       serv_puts(tmpemail);
-       serv_puts(tmpcountry);
-       serv_puts("000");
        scr_printf("\n");
 }
 
 void updatels(void)
 {                              /* make all messages old in current room */
        char buf[SIZ];
+       int r;                          /* IPC response code */
 
        if (rc_alt_semantics) {
                if (maxmsgnum == highest_msg_read == 0) {
                        /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
                        return;
                }
-               snprintf(buf, sizeof(buf), "SLRP %ld",
-                               (maxmsgnum > highest_msg_read) ?
-                                maxmsgnum : highest_msg_read);
-               serv_puts(buf);
+               r = CtdlIPCSetLastRead((maxmsgnum > highest_msg_read) ?
+                                maxmsgnum : highest_msg_read, buf);
        } else {
-               serv_puts("SLRP HIGHEST");
+               r = CtdlIPCSetLastRead(0, buf);
        }
-       serv_gets(buf);
-       if (buf[0] != '2')
-               scr_printf("%s\n", &buf[4]);
+       if (r / 100 != 2)
+               scr_printf("%s\n", buf);
 }
 
 /*
@@ -211,11 +208,10 @@ void updatels(void)
 void updatelsa(void)
 {
        char buf[SIZ];
+       int r;                          /* IPC response code */
 
-       snprintf(buf, sizeof buf, "SLRP %ld", highest_msg_read);
-       serv_puts(buf);
-       serv_gets(buf);
-       if (buf[0] != '2')
+       r = CtdlIPCSetLastRead(highest_msg_read, buf);
+       if (r / 100 != 2)
                scr_printf("%s\n", &buf[4]);
 }
 
@@ -485,6 +481,7 @@ void val_user(char *user, int do_validate)
        char cmd[SIZ];
        char buf[SIZ];
        int ax = 0;
+       int r;                          /* IPC response code */
 
        snprintf(cmd, sizeof cmd, "GREG %s", user);
        serv_puts(cmd);
@@ -525,11 +522,9 @@ void val_user(char *user, int do_validate)
        if (do_validate) {
                /* now set the access level */
                ax = intprompt("Access level", ax, 0, 6);
-               snprintf(cmd, sizeof cmd, "VALI %s|%d", user, ax);
-               serv_puts(cmd);
-               serv_gets(cmd);
-               if (cmd[0] != '2')
-                       scr_printf("%s\n", &cmd[4]);
+               r = CtdlIPCValidateUser(user, ax, cmd);
+               if (r / 100 != 2)
+                       scr_printf("%s\n", cmd);
        }
        scr_printf("\n");
 }
@@ -540,17 +535,17 @@ void validate(void)
        char cmd[SIZ];
        char buf[SIZ];
        int finished = 0;
+       int r;                          /* IPC response code */
 
        do {
-               serv_puts("GNUR");
-               serv_gets(cmd);
-               if (cmd[0] != '3')
+               r = CtdlIPCNextUnvalidatedUser(cmd);
+               if (r / 100 != 3)
                        finished = 1;
-               if (cmd[0] == '2')
-                       scr_printf("%s\n", &cmd[4]);
-               if (cmd[0] == '3') {
+               if (r / 100 == 2)
+                       scr_printf("%s\n", cmd);
+               if (r / 100 == 3) {
                        extract(buf, cmd, 0);
-                       val_user(&buf[4], 1);
+                       val_user(buf, 1);
                }
        } while (finished == 0);
 }
@@ -581,15 +576,13 @@ void subshell(void)
 void deletefile(void)
 {
        char filename[32];
-       char cmd[SIZ];
+       char buf[SIZ];
 
        newprompt("Filename: ", filename, 31);
        if (strlen(filename) == 0)
                return;
-       snprintf(cmd, sizeof cmd, "DELF %s", filename);
-       serv_puts(cmd);
-       serv_gets(cmd);
-       err_printf("%s\n", &cmd[4]);
+       CtdlIPCDeleteFile(filename, buf);
+       err_printf("%s\n", buf);
 }
 
 /*
@@ -597,16 +590,14 @@ void deletefile(void)
  */
 void netsendfile(void)
 {
-       char filename[32], destsys[20], cmd[SIZ];
+       char filename[32], destsys[20], buf[SIZ];
 
        newprompt("Filename: ", filename, 31);
        if (strlen(filename) == 0)
                return;
        newprompt("System to send to: ", destsys, 19);
-       snprintf(cmd, sizeof cmd, "NETF %s|%s", filename, destsys);
-       serv_puts(cmd);
-       serv_gets(cmd);
-       err_printf("%s\n", &cmd[4]);
+       CtdlIPCNetSendFile(filename, destsys, buf);
+       err_printf("%s\n", buf);
        return;
 }
 
@@ -617,17 +608,14 @@ void movefile(void)
 {
        char filename[64];
        char newroom[ROOMNAMELEN];
-       char cmd[SIZ];
+       char buf[SIZ];
 
        newprompt("Filename: ", filename, 63);
        if (strlen(filename) == 0)
                return;
        newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
-
-       snprintf(cmd, sizeof cmd, "MOVF %s|%s", filename, newroom);
-       serv_puts(cmd);
-       serv_gets(cmd);
-       err_printf("%s\n", &cmd[4]);
+       CtdlIPCMoveFile(filename, newroom, buf);
+       err_printf("%s\n", buf);
 }
 
 
diff --git a/citadel/serv_info.c b/citadel/serv_info.c
deleted file mode 100644 (file)
index 675a69b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $Id$
- *
- * The CtdlGetServerInfo() function is useful for removing unsightly 
- * uranium deposits from rhinocerous aqueducts.
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#include <ctype.h>
-#include <string.h>
-#include <errno.h>
-#include "citadel.h"
-#include "serv_info.h"
-
-void CtdlInternalGetServInfo(struct CtdlServInfo *infobuf) {
-       char buf[SIZ];
-       int a;
-
-       /* fetch info */        
-       serv_puts("INFO");
-       serv_gets(buf);
-       if (buf[0]!='1') return;
-
-       memset(infobuf, 0, sizeof(struct CtdlServInfo));
-       a = 0;
-       while(serv_gets(buf), strcmp(buf,"000")) {
-           switch(a) {
-               case 0:         infobuf->serv_pid = atoi(buf);
-                               break;
-               case 1:         strcpy(infobuf->serv_nodename,buf);
-                               break;
-               case 2:         strcpy(infobuf->serv_humannode,buf);
-                               break;
-               case 3:         strcpy(infobuf->serv_fqdn,buf);
-                               break;
-               case 4:         strcpy(infobuf->serv_software,buf);
-                               break;
-               case 5:         infobuf->serv_rev_level = atoi(buf);
-                               break;
-               case 6:         strcpy(infobuf->serv_bbs_city,buf);
-                               break;
-               case 7:         strcpy(infobuf->serv_sysadm,buf);
-                               break;
-               case 9:         strcpy(infobuf->serv_moreprompt,buf);
-                               break;
-               case 10:        infobuf->serv_ok_floors = atoi(buf);
-                               break;
-               case 11:        infobuf->serv_paging_level = atoi(buf);
-                               break;
-               case 13:        infobuf->serv_supports_qnop = atoi(buf);
-                               break;
-               }
-           ++a;
-           }
-
-       }
-
diff --git a/citadel/serv_info.h b/citadel/serv_info.h
deleted file mode 100644 (file)
index 7077114..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* $Id$ */
-void CtdlInternalGetServInfo(struct CtdlServInfo *infobuf);