3 * More client-side support functions.
4 * Unlike routines.c, some of these DO use global variables.
11 #include <sys/types.h>
19 #if TIME_WITH_SYS_TIME
20 # include <sys/time.h>
24 # include <sys/time.h>
36 #include "citadel_ipc.h"
37 #include "citadel_decls.h"
38 #include "routines2.h"
49 extern char tempdir[];
50 extern char *axdefs[7];
51 extern long highest_msg_read;
52 extern long maxmsgnum;
53 extern unsigned room_flags;
54 extern int screenwidth;
58 int eopen(char *name, int mode)
61 ret = open(name, mode);
63 err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
72 int room_prompt(unsigned int qrflags)
73 { /* return proper room prompt character */
76 if (qrflags & QR_DIRECTORY)
78 if ((a == ']') && (qrflags & QR_NETWORK))
80 if ((a == '>') && (qrflags & QR_NETWORK))
85 void entregis(CtdlIPC *ipc)
86 { /* register with name and address */
102 int r; /* IPC response code */
107 strcpy(tmpstate, "");
109 strcpy(tmpphone, "");
110 strcpy(tmpemail, "");
111 strcpy(tmpcountry, "");
113 r = CtdlIPCGetUserRegistration(ipc, NULL, ®, buf);
117 while (reg && strlen(reg) > 0) {
119 extract_token(buf, reg, 0, '\n');
120 remove_token(reg, 0, '\n');
123 strcpy(tmpname, buf);
125 strcpy(tmpaddr, buf);
127 strcpy(tmpcity, buf);
129 strcpy(tmpstate, buf);
133 strcpy(tmpphone, buf);
135 strcpy(tmpemail, buf);
137 strcpy(tmpcountry, buf);
141 strprompt("REAL name", tmpname, 29);
142 strprompt("Address", tmpaddr, 24);
143 strprompt("City/town", tmpcity, 14);
144 strprompt("State/province", tmpstate, 2);
145 strprompt("ZIP/Postal Code", tmpzip, 10);
146 strprompt("Country", tmpcountry, 31);
147 strprompt("Telephone number", tmpphone, 14);
151 strcpy(holdemail, tmpemail);
152 strprompt("Email address", tmpemail, 31);
153 r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
155 extract_token(diruser, buf, 0, '@');
156 extract_token(dirnode, buf, 1, '@');
159 if ((strcasecmp(diruser, fullname))
160 || (strcasecmp(dirnode, serv_info.serv_nodename))) {
162 "\nYou can't use %s as your address.\n",
165 "It is already in use by %s @ %s.\n",
168 strcpy(tmpemail, holdemail);
173 /* now send the registration info back to the server */
174 reg = (char *)realloc(reg, 4096); /* Overkill? */
176 sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
177 tmpname, tmpaddr, tmpcity, tmpstate,
178 tmpzip, tmpphone, tmpemail, tmpcountry);
179 r = CtdlIPCSetRegistration(ipc, reg, buf);
181 scr_printf("%s\n", buf);
187 void updatels(CtdlIPC *ipc)
188 { /* make all messages old in current room */
190 int r; /* IPC response code */
192 if (rc_alt_semantics) {
193 if (maxmsgnum == highest_msg_read == 0) {
194 /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
197 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
198 maxmsgnum : highest_msg_read, buf);
200 r = CtdlIPCSetLastRead(ipc, 0, buf);
203 scr_printf("%s\n", buf);
207 * only make messages old in this room that have been read
209 void updatelsa(CtdlIPC *ipc)
212 int r; /* IPC response code */
214 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
216 scr_printf("%s\n", &buf[4]);
221 * client-based uploads (for users with their own clientware)
223 void cli_upload(CtdlIPC *ipc)
229 int r; /* IPC response code */
233 if ((room_flags & QR_UPLOAD) == 0) {
234 scr_printf("*** You cannot upload to this room.\n");
237 newprompt("File to be uploaded: ", flnm, 55);
238 fd = open(flnm, O_RDONLY);
240 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
243 scr_printf("Enter a description of this file:\n");
244 newprompt(": ", desc, 75);
246 /* Keep generating filenames in hope of finding a unique one */
249 /* basename of filename */
251 if (haschar(tbuf, '/'))
252 strcpy(tbuf, strrchr(tbuf, '/'));
253 /* filename.1, filename.2, etc */
255 sprintf(buf + strlen(buf), ".%d", a);
258 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
259 if (r / 100 == 5 || r < 0)
260 scr_printf("%s\n", buf);
269 * Function used for various image upload commands
271 void cli_image_upload(CtdlIPC *ipc, char *keyname)
277 /* Can we upload this image? */
278 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
280 err_printf("%s\n", buf);
283 newprompt("Image file to be uploaded: ", flnm, 55);
284 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
286 err_printf("%s\n", buf);
288 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
290 /* else upload succeeded */
295 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
297 void upload(CtdlIPC *ipc, int c)
298 { /* c = upload mode */
308 if ((room_flags & QR_UPLOAD) == 0) {
309 scr_printf("*** You cannot upload to this room.\n");
312 /* we don't need a filename when receiving batch y/z modem */
313 if ((c == 2) || (c == 3))
316 newprompt("Enter filename: ", flnm, 15);
318 for (a = 0; a < strlen(flnm); ++a)
319 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
320 || (flnm[a] == '?') || (flnm[a] == '*')
321 || (flnm[a] == ';') || (flnm[a] == '&'))
324 /* create a temporary directory... */
325 if (mkdir(tempdir, 0700) != 0) {
326 scr_printf("*** Could not create temporary directory %s: %s\n",
327 tempdir, strerror(errno));
330 /* now do the transfer ... in a separate process */
337 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
338 fp = fopen(flnm, "w");
354 execlp("rx", "rx", flnm, NULL);
359 execlp("rb", "rb", NULL);
364 execlp("rz", "rz", NULL);
370 } while ((b != xfer_pid) && (b != (-1)));
375 scr_printf("\r*** Transfer unsuccessful.\n");
379 scr_printf("\r*** Transfer successful.\n");
380 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
381 lsfp = popen(buf, "r");
383 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
384 flnm[strlen(flnm) - 1] = 0; /* chop newline */
385 snprintf(buf, sizeof buf,
386 "Enter a short description of '%s':\n: ",
388 newprompt(buf, desc, 150);
389 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
390 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
391 scr_printf("%s\n", tbuf);
401 void val_user(CtdlIPC *ipc, char *user, int do_validate)
407 int r; /* IPC response code */
409 snprintf(cmd, sizeof cmd, "GREG %s", user);
410 CtdlIPC_putline(ipc, cmd);
411 CtdlIPC_getline(ipc, cmd);
415 CtdlIPC_getline(ipc, buf);
418 scr_printf("User #%s - %s ", buf, &cmd[4]);
420 scr_printf("PW: %s\n", buf);
422 scr_printf("%s\n", buf);
424 scr_printf("%s\n", buf);
426 scr_printf("%s, ", buf);
428 scr_printf("%s ", buf);
430 scr_printf("%s\n", buf);
432 scr_printf("%s\n", buf);
436 scr_printf("%s\n", buf);
438 scr_printf("%s\n", buf);
439 } while (strcmp(buf, "000"));
440 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
442 scr_printf("%-30s\n%s\n", user, &cmd[4]);
446 /* now set the access level */
447 ax = intprompt("Access level", ax, 0, 6);
448 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
450 scr_printf("%s\n", cmd);
456 void validate(CtdlIPC *ipc)
457 { /* validate new users */
461 int r; /* IPC response code */
464 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
468 scr_printf("%s\n", cmd);
470 extract(buf, cmd, 0);
471 val_user(ipc, buf, 1);
473 } while (finished == 0);
483 signal(SIGINT, SIG_DFL);
484 signal(SIGQUIT, SIG_DFL);
485 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
486 err_printf("Could not open a shell: %s\n", strerror(errno));
491 } while ((a != b) && (a != (-1)));
497 * <.A>ide <F>ile <D>elete command
499 void deletefile(CtdlIPC *ipc)
504 newprompt("Filename: ", filename, 31);
505 if (strlen(filename) == 0)
507 CtdlIPCDeleteFile(ipc, filename, buf);
508 err_printf("%s\n", buf);
512 * <.A>ide <F>ile <S>end command
514 void netsendfile(CtdlIPC *ipc)
516 char filename[32], destsys[20], buf[SIZ];
518 newprompt("Filename: ", filename, 31);
519 if (strlen(filename) == 0)
521 newprompt("System to send to: ", destsys, 19);
522 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
523 err_printf("%s\n", buf);
528 * <.A>ide <F>ile <M>ove command
530 void movefile(CtdlIPC *ipc)
533 char newroom[ROOMNAMELEN];
536 newprompt("Filename: ", filename, 63);
537 if (strlen(filename) == 0)
539 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
540 CtdlIPCMoveFile(ipc, filename, newroom, buf);
541 err_printf("%s\n", buf);
546 * list of users who have filled out a bio
548 void list_bio(CtdlIPC *ipc)
553 CtdlIPC_putline(ipc, "LBIO");
554 CtdlIPC_getline(ipc, buf);
556 pprintf("%s\n", &buf[4]);
559 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
560 if ((pos + strlen(buf) + 5) > screenwidth) {
564 pprintf("%s, ", buf);
565 pos = pos + strlen(buf) + 2;
567 pprintf("%c%c \n\n", 8, 8);
574 void read_bio(CtdlIPC *ipc)
580 newprompt("Read bio for who ('?' for list) : ", who, 25);
582 if (!strcmp(who, "?"))
584 } while (!strcmp(who, "?"));
585 snprintf(buf, sizeof buf, "RBIO %s", who);
586 CtdlIPC_putline(ipc, buf);
587 CtdlIPC_getline(ipc, buf);
589 pprintf("%s\n", &buf[4]);
592 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
593 pprintf("%s\n", buf);
599 * General system configuration command
601 void do_system_configuration(CtdlIPC *ipc)
606 int expire_value = 0;
610 /* Clear out the config buffers */
611 memset(&sc[0][0], 0, sizeof(sc));
613 /* Fetch the current config */
614 CtdlIPC_putline(ipc, "CONF get");
615 CtdlIPC_getline(ipc, buf);
618 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
620 strcpy(&sc[a][0], buf);
625 /* Fetch the expire policy (this will silently fail on old servers,
626 * resulting in "default" policy)
628 CtdlIPC_putline(ipc, "GPEX site");
629 CtdlIPC_getline(ipc, buf);
631 expire_mode = extract_int(&buf[4], 0);
632 expire_value = extract_int(&buf[4], 1);
636 /* Identification parameters */
638 strprompt("Node name", &sc[0][0], 15);
639 strprompt("Fully qualified domain name", &sc[1][0], 63);
640 strprompt("Human readable node name", &sc[2][0], 20);
641 strprompt("Modem dialup number", &sc[3][0], 15);
642 strprompt("Geographic location of this system", &sc[12][0], 31);
643 strprompt("Name of system administrator", &sc[13][0], 25);
644 strprompt("Paginator prompt", &sc[10][0], 79);
646 /* Security parameters */
648 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
649 "Require registration for new users",
651 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
652 "Disable self-service user account creation",
654 strprompt("Initial access level for new users", &sc[6][0], 1);
655 strprompt("Access level required to create rooms", &sc[19][0], 1);
656 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
657 "Automatically give room aide privs to a user who creates a private room",
660 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
661 "Automatically move problem user messages to twit room",
664 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
665 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
666 "Restrict Internet mail to only those with that privilege",
668 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
669 "Allow Aides to Zap (forget) rooms",
671 snprintf(sc[30], sizeof sc[29], "%d", (boolprompt(
672 "Allow system Aides access to user mailboxes",
675 if (strlen(&sc[18][0]) > 0) logpages = 1;
677 logpages = boolprompt("Log all pages", logpages);
679 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
688 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
689 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
690 strprompt("Maximum message length", &sc[20][0], 20);
691 strprompt("Minimum number of worker threads", &sc[21][0], 3);
692 strprompt("Maximum number of worker threads", &sc[22][0], 3);
694 /* no longer applicable ... deprecated
695 strprompt("Server-to-server networking password", &sc[15][0], 19);
698 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
699 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
700 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
701 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
703 /* Expiry settings */
704 strprompt("Default user purge time (days)", &sc[16][0], 5);
705 strprompt("Default room purge time (days)", &sc[17][0], 5);
707 /* Angels and demons dancing in my head... */
709 snprintf(buf, sizeof buf, "%d", expire_mode);
710 strprompt("System default message expire policy (? for list)",
714 "1. Never automatically expire messages\n"
715 "2. Expire by message count\n"
716 "3. Expire by message age\n");
718 } while ((buf[0] < 49) || (buf[0] > 51));
719 expire_mode = buf[0] - 48;
721 /* ...lunatics and monsters underneath my bed */
722 if (expire_mode == 2) {
723 snprintf(buf, sizeof buf, "%d", expire_value);
724 strprompt("Keep how many messages online?", buf, 10);
725 expire_value = atol(buf);
727 if (expire_mode == 3) {
728 snprintf(buf, sizeof buf, "%d", expire_value);
729 strprompt("Keep messages for how many days?", buf, 10);
730 expire_value = atol(buf);
733 scr_printf("Save this configuration? ");
735 CtdlIPC_putline(ipc, "CONF set");
736 CtdlIPC_getline(ipc, buf);
738 for (a = 0; a < 31; ++a)
739 CtdlIPC_putline(ipc, &sc[a][0]);
740 CtdlIPC_putline(ipc, "000");
742 snprintf(buf, sizeof buf, "SPEX site|%d|%d",
743 expire_mode, expire_value);
744 CtdlIPC_putline(ipc, buf);
745 CtdlIPC_getline(ipc, buf);
751 * support function for do_internet_configuration()
753 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
756 keyopt(" <1> localhost (Alias for this computer)\n");
757 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
758 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
759 keyopt(" <4> directory (Consult the Global Address Book)\n");
760 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
761 sel = intprompt("Which one", 1, 1, 5);
763 case 1: strcpy(buf, "localhost");
765 case 2: strcpy(buf, "gatewaydomain");
767 case 3: strcpy(buf, "smarthost");
769 case 4: strcpy(buf, "directory");
771 case 5: strcpy(buf, "spamassassin");
778 * Internet mail configuration
780 void do_internet_configuration(CtdlIPC *ipc)
791 snprintf(buf, sizeof buf, "CONF getsys|%s", INTERNETCFG);
792 CtdlIPC_putline(ipc, buf);
793 CtdlIPC_getline(ipc, buf);
794 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
796 if (num_recs == 1) recs = malloc(sizeof(char *));
797 else recs = realloc(recs, (sizeof(char *)) * num_recs);
798 recs[num_recs-1] = malloc(SIZ);
799 strcpy(recs[num_recs-1], buf);
805 scr_printf("### Host or domain Record type \n");
807 scr_printf("--- -------------------------------------------------- --------------------\n");
808 for (i=0; i<num_recs; ++i) {
810 scr_printf("%3d ", i+1);
811 extract(buf, recs[i], 0);
813 scr_printf("%-50s ", buf);
814 extract(buf, recs[i], 1);
815 color(BRIGHT_MAGENTA);
816 scr_printf("%-20s\n", buf);
820 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
825 recs = malloc(sizeof(char *));
826 else recs = realloc(recs,
827 (sizeof(char *)) * num_recs);
828 newprompt("Enter host name: ",
831 get_inet_rec_type(ipc, &buf[strlen(buf)]);
832 recs[num_recs-1] = strdup(buf);
835 i = intprompt("Delete which one",
839 for (j=i; j<num_recs; ++j)
843 snprintf(buf, sizeof buf, "CONF putsys|%s",
845 CtdlIPC_putline(ipc, buf);
846 CtdlIPC_getline(ipc, buf);
848 for (i=0; i<num_recs; ++i) {
849 CtdlIPC_putline(ipc, recs[i]);
851 CtdlIPC_putline(ipc, "000");
854 scr_printf("%s\n", &buf[4]);
859 quitting = boolprompt(
860 "Quit without saving", 0);
865 } while (quitting == 0);
868 for (i=0; i<num_recs; ++i) free(recs[i]);
876 * Edit network configuration for room sharing, mailing lists, etc.
878 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
880 char filename[PATH_MAX];
881 char changefile[PATH_MAX];
892 if (strlen(editor_path) == 0) {
893 scr_printf("You must have an external editor configured in"
894 " order to use this function.\n");
898 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
899 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
901 tempfp = fopen(filename, "w");
902 if (tempfp == NULL) {
903 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
907 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
908 fprintf(tempfp, "# %s\n", comment);
909 fprintf(tempfp, "# Specify one per line.\n"
912 CtdlIPC_putline(ipc, "GNET");
913 CtdlIPC_getline(ipc, buf);
915 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
916 extract(instr, buf, 0);
917 if (!strcasecmp(instr, entrytype)) {
918 extract(addr, buf, 1);
919 fprintf(tempfp, "%s\n", addr);
925 e_ex_code = 1; /* start with a failed exit code */
927 cksum = file_checksum(filename);
928 if (editor_pid == 0) {
929 chmod(filename, 0600);
932 putenv("WINDOW_TITLE=Network configuration");
933 execlp(editor_path, editor_path, filename, NULL);
936 if (editor_pid > 0) {
939 b = ka_wait(&e_ex_code);
940 } while ((b != editor_pid) && (b >= 0));
946 if (file_checksum(filename) == cksum) {
947 err_printf("*** Not saving changes.\n");
951 if (e_ex_code == 0) { /* Save changes */
952 changefp = fopen(changefile, "w");
953 CtdlIPC_putline(ipc, "GNET");
954 CtdlIPC_getline(ipc, buf);
956 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
957 extract(instr, buf, 0);
958 if (strcasecmp(instr, entrytype)) {
959 fprintf(changefp, "%s\n", buf);
963 tempfp = fopen(filename, "r");
964 while (fgets(buf, sizeof buf, tempfp) != NULL) {
965 for (i=0; i<strlen(buf); ++i) {
966 if (buf[i] == '#') buf[i] = 0;
969 if (strlen(buf) > 0) {
970 fprintf(changefp, "%s|%s\n", entrytype, buf);
976 /* now write it to the server... */
977 CtdlIPC_putline(ipc, "SNET");
978 CtdlIPC_getline(ipc, buf);
980 changefp = fopen(changefile, "r");
981 if (changefp != NULL) {
982 while (fgets(buf, sizeof buf,
984 buf[strlen(buf) - 1] = 0;
985 CtdlIPC_putline(ipc, buf);
989 CtdlIPC_putline(ipc, "000");
993 unlink(filename); /* Delete the temporary files */
999 * IGnet node configuration
1001 void do_ignet_configuration(CtdlIPC *ipc) {
1011 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1012 CtdlIPC_putline(ipc, buf);
1013 CtdlIPC_getline(ipc, buf);
1014 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1016 if (num_recs == 1) recs = malloc(sizeof(char *));
1017 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1018 recs[num_recs-1] = malloc(SIZ);
1019 strcpy(recs[num_recs-1], buf);
1024 color(BRIGHT_WHITE);
1033 "------------------ "
1034 "-------------------------------- "
1036 for (i=0; i<num_recs; ++i) {
1038 scr_printf("%3d ", i+1);
1039 extract(buf, recs[i], 0);
1041 scr_printf("%-16s ", buf);
1042 extract(buf, recs[i], 1);
1043 color(BRIGHT_MAGENTA);
1044 scr_printf("%-18s ", buf);
1045 extract(buf, recs[i], 2);
1047 scr_printf("%-32s ", buf);
1048 extract(buf, recs[i], 3);
1049 color(BRIGHT_MAGENTA);
1050 scr_printf("%-3s\n", buf);
1054 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1059 recs = malloc(sizeof(char *));
1060 else recs = realloc(recs,
1061 (sizeof(char *)) * num_recs);
1062 newprompt("Enter node name : ", buf, 16);
1064 newprompt("Enter shared secret: ",
1065 &buf[strlen(buf)], 18);
1067 newprompt("Enter host or IP : ",
1068 &buf[strlen(buf)], 32);
1069 strcat(buf, "|504");
1070 strprompt("Enter port number : ",
1071 &buf[strlen(buf)-3], 5);
1072 recs[num_recs-1] = strdup(buf);
1075 i = intprompt("Delete which one",
1076 1, 1, num_recs) - 1;
1079 for (j=i; j<num_recs; ++j)
1080 recs[j] = recs[j+1];
1083 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1084 CtdlIPC_putline(ipc, buf);
1085 CtdlIPC_getline(ipc, buf);
1086 if (buf[0] == '4') {
1087 for (i=0; i<num_recs; ++i) {
1088 CtdlIPC_putline(ipc, recs[i]);
1090 CtdlIPC_putline(ipc, "000");
1093 scr_printf("%s\n", &buf[4]);
1098 quitting = boolprompt(
1099 "Quit without saving", 0);
1104 } while (quitting == 0);
1107 for (i=0; i<num_recs; ++i) free(recs[i]);
1113 * Filter list configuration
1115 void do_filterlist_configuration(CtdlIPC *ipc)
1126 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1127 CtdlIPC_putline(ipc, buf);
1128 CtdlIPC_getline(ipc, buf);
1129 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1131 if (num_recs == 1) recs = malloc(sizeof(char *));
1132 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1133 recs[num_recs-1] = malloc(SIZ);
1134 strcpy(recs[num_recs-1], buf);
1139 color(BRIGHT_WHITE);
1147 "---------------------------- "
1148 "---------------------------- "
1151 for (i=0; i<num_recs; ++i) {
1153 scr_printf("%3d ", i+1);
1154 extract(buf, recs[i], 0);
1156 scr_printf("%-28s ", buf);
1157 extract(buf, recs[i], 1);
1158 color(BRIGHT_MAGENTA);
1159 scr_printf("%-28s ", buf);
1160 extract(buf, recs[i], 2);
1162 scr_printf("%-16s\n", buf);
1163 extract(buf, recs[i], 3);
1167 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1172 recs = malloc(sizeof(char *));
1173 else recs = realloc(recs,
1174 (sizeof(char *)) * num_recs);
1175 newprompt("Enter user name: ", buf, 28);
1177 newprompt("Enter room name: ",
1178 &buf[strlen(buf)], 28);
1180 newprompt("Enter node name: ",
1181 &buf[strlen(buf)], 16);
1183 recs[num_recs-1] = strdup(buf);
1186 i = intprompt("Delete which one",
1187 1, 1, num_recs) - 1;
1190 for (j=i; j<num_recs; ++j)
1191 recs[j] = recs[j+1];
1194 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1195 CtdlIPC_putline(ipc, buf);
1196 CtdlIPC_getline(ipc, buf);
1197 if (buf[0] == '4') {
1198 for (i=0; i<num_recs; ++i) {
1199 CtdlIPC_putline(ipc, recs[i]);
1201 CtdlIPC_putline(ipc, "000");
1204 scr_printf("%s\n", &buf[4]);
1209 quitting = boolprompt(
1210 "Quit without saving", 0);
1215 } while (quitting == 0);
1218 for (i=0; i<num_recs; ++i) free(recs[i]);