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"
47 #include "client_crypto.h"
50 extern char tempdir[];
51 extern char *axdefs[7];
52 extern long highest_msg_read;
53 extern long maxmsgnum;
54 extern unsigned room_flags;
55 extern int screenwidth;
59 int eopen(char *name, int mode)
62 ret = open(name, mode);
64 err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
73 int room_prompt(int qrflags)
74 { /* return proper room prompt character */
77 if (qrflags & QR_DIRECTORY)
79 if ((a == ']') && (qrflags & QR_NETWORK))
81 if ((a == '>') && (qrflags & QR_NETWORK))
86 void entregis(CtdlIPC *ipc)
87 { /* register with name and address */
103 int r; /* IPC response code */
108 strcpy(tmpstate, "");
110 strcpy(tmpphone, "");
111 strcpy(tmpemail, "");
112 strcpy(tmpcountry, "");
114 r = CtdlIPCGetUserRegistration(ipc, NULL, ®, buf);
118 while (reg && strlen(reg) > 0) {
120 extract_token(buf, reg, 0, '\n');
121 remove_token(reg, 0, '\n');
124 strcpy(tmpname, buf);
126 strcpy(tmpaddr, buf);
128 strcpy(tmpcity, buf);
130 strcpy(tmpstate, buf);
134 strcpy(tmpphone, buf);
136 strcpy(tmpemail, buf);
138 strcpy(tmpcountry, buf);
142 strprompt("REAL name", tmpname, 29);
143 strprompt("Address", tmpaddr, 24);
144 strprompt("City/town", tmpcity, 14);
145 strprompt("State/province", tmpstate, 2);
146 strprompt("ZIP/Postal Code", tmpzip, 10);
147 strprompt("Country", tmpcountry, 31);
148 strprompt("Telephone number", tmpphone, 14);
152 strcpy(holdemail, tmpemail);
153 strprompt("Email address", tmpemail, 31);
154 r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
156 extract_token(diruser, buf, 0, '@');
157 extract_token(dirnode, buf, 1, '@');
160 if ((strcasecmp(diruser, fullname))
161 || (strcasecmp(dirnode, serv_info.serv_nodename))) {
163 "\nYou can't use %s as your address.\n",
166 "It is already in use by %s @ %s.\n",
169 strcpy(tmpemail, holdemail);
174 /* now send the registration info back to the server */
175 reg = (char *)realloc(reg, 4096); /* Overkill? */
177 sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
178 tmpname, tmpaddr, tmpcity, tmpstate,
179 tmpzip, tmpphone, tmpemail, tmpcountry);
180 r = CtdlIPCSetRegistration(ipc, reg, buf);
182 scr_printf("%s\n", buf);
188 void updatels(CtdlIPC *ipc)
189 { /* make all messages old in current room */
191 int r; /* IPC response code */
193 if (rc_alt_semantics) {
194 if (maxmsgnum == highest_msg_read == 0) {
195 /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
198 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
199 maxmsgnum : highest_msg_read, buf);
201 r = CtdlIPCSetLastRead(ipc, 0, buf);
204 scr_printf("%s\n", buf);
208 * only make messages old in this room that have been read
210 void updatelsa(CtdlIPC *ipc)
213 int r; /* IPC response code */
215 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
217 scr_printf("%s\n", &buf[4]);
222 * client-based uploads (for users with their own clientware)
224 void cli_upload(CtdlIPC *ipc)
230 int r; /* IPC response code */
234 if ((room_flags & QR_UPLOAD) == 0) {
235 scr_printf("*** You cannot upload to this room.\n");
238 newprompt("File to be uploaded: ", flnm, 55);
239 fd = open(flnm, O_RDONLY);
241 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
244 scr_printf("Enter a description of this file:\n");
245 newprompt(": ", desc, 75);
247 /* Keep generating filenames in hope of finding a unique one */
250 /* basename of filename */
252 if (haschar(tbuf, '/'))
253 strcpy(tbuf, strrchr(tbuf, '/'));
254 /* filename.1, filename.2, etc */
256 sprintf(buf + strlen(buf), ".%d", a);
259 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
260 if (r / 100 == 5 || r < 0)
261 scr_printf("%s\n", buf);
270 * Function used for various image upload commands
272 void cli_image_upload(CtdlIPC *ipc, char *keyname)
278 /* Can we upload this image? */
279 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
281 err_printf("%s\n", buf);
284 newprompt("Image file to be uploaded: ", flnm, 55);
285 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
287 err_printf("%s\n", buf);
289 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
291 /* else upload succeeded */
296 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
298 void upload(CtdlIPC *ipc, int c)
299 { /* c = upload mode */
309 if ((room_flags & QR_UPLOAD) == 0) {
310 scr_printf("*** You cannot upload to this room.\n");
313 /* we don't need a filename when receiving batch y/z modem */
314 if ((c == 2) || (c == 3))
317 newprompt("Enter filename: ", flnm, 15);
319 for (a = 0; a < strlen(flnm); ++a)
320 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
321 || (flnm[a] == '?') || (flnm[a] == '*')
322 || (flnm[a] == ';') || (flnm[a] == '&'))
325 /* create a temporary directory... */
326 if (mkdir(tempdir, 0700) != 0) {
327 scr_printf("*** Could not create temporary directory %s: %s\n",
328 tempdir, strerror(errno));
331 /* now do the transfer ... in a separate process */
338 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
339 fp = fopen(flnm, "w");
355 execlp("rx", "rx", flnm, NULL);
360 execlp("rb", "rb", NULL);
365 execlp("rz", "rz", NULL);
371 } while ((b != xfer_pid) && (b != (-1)));
376 scr_printf("\r*** Transfer unsuccessful.\n");
380 scr_printf("\r*** Transfer successful.\n");
381 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
382 lsfp = popen(buf, "r");
384 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
385 flnm[strlen(flnm) - 1] = 0; /* chop newline */
386 snprintf(buf, sizeof buf,
387 "Enter a short description of '%s':\n: ",
389 newprompt(buf, desc, 150);
390 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
391 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
392 scr_printf("%s\n", tbuf);
402 void val_user(CtdlIPC *ipc, char *user, int do_validate)
408 int r; /* IPC response code */
410 snprintf(cmd, sizeof cmd, "GREG %s", user);
411 CtdlIPC_putline(ipc, cmd);
412 CtdlIPC_getline(ipc, cmd);
416 CtdlIPC_getline(ipc, buf);
419 scr_printf("User #%s - %s ", buf, &cmd[4]);
421 scr_printf("PW: %s\n", buf);
423 scr_printf("%s\n", buf);
425 scr_printf("%s\n", buf);
427 scr_printf("%s, ", buf);
429 scr_printf("%s ", buf);
431 scr_printf("%s\n", buf);
433 scr_printf("%s\n", buf);
437 scr_printf("%s\n", buf);
439 scr_printf("%s\n", buf);
440 } while (strcmp(buf, "000"));
441 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
443 scr_printf("%-30s\n%s\n", user, &cmd[4]);
447 /* now set the access level */
448 ax = intprompt("Access level", ax, 0, 6);
449 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
451 scr_printf("%s\n", cmd);
457 void validate(CtdlIPC *ipc)
458 { /* validate new users */
462 int r; /* IPC response code */
465 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
469 scr_printf("%s\n", cmd);
471 extract(buf, cmd, 0);
472 val_user(ipc, buf, 1);
474 } while (finished == 0);
484 signal(SIGINT, SIG_DFL);
485 signal(SIGQUIT, SIG_DFL);
486 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
487 err_printf("Could not open a shell: %s\n", strerror(errno));
492 } while ((a != b) && (a != (-1)));
498 * <.A>ide <F>ile <D>elete command
500 void deletefile(CtdlIPC *ipc)
505 newprompt("Filename: ", filename, 31);
506 if (strlen(filename) == 0)
508 CtdlIPCDeleteFile(ipc, filename, buf);
509 err_printf("%s\n", buf);
513 * <.A>ide <F>ile <S>end command
515 void netsendfile(CtdlIPC *ipc)
517 char filename[32], destsys[20], buf[SIZ];
519 newprompt("Filename: ", filename, 31);
520 if (strlen(filename) == 0)
522 newprompt("System to send to: ", destsys, 19);
523 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
524 err_printf("%s\n", buf);
529 * <.A>ide <F>ile <M>ove command
531 void movefile(CtdlIPC *ipc)
534 char newroom[ROOMNAMELEN];
537 newprompt("Filename: ", filename, 63);
538 if (strlen(filename) == 0)
540 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
541 CtdlIPCMoveFile(ipc, filename, newroom, buf);
542 err_printf("%s\n", buf);
547 * list of users who have filled out a bio
549 void list_bio(CtdlIPC *ipc)
554 CtdlIPC_putline(ipc, "LBIO");
555 CtdlIPC_getline(ipc, buf);
557 pprintf("%s\n", &buf[4]);
560 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
561 if ((pos + strlen(buf) + 5) > screenwidth) {
565 pprintf("%s, ", buf);
566 pos = pos + strlen(buf) + 2;
568 pprintf("%c%c \n\n", 8, 8);
575 void read_bio(CtdlIPC *ipc)
581 newprompt("Read bio for who ('?' for list) : ", who, 25);
583 if (!strcmp(who, "?"))
585 } while (!strcmp(who, "?"));
586 snprintf(buf, sizeof buf, "RBIO %s", who);
587 CtdlIPC_putline(ipc, buf);
588 CtdlIPC_getline(ipc, buf);
590 pprintf("%s\n", &buf[4]);
593 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
594 pprintf("%s\n", buf);
600 * General system configuration command
602 void do_system_configuration(CtdlIPC *ipc)
607 int expire_value = 0;
611 /* Clear out the config buffers */
612 memset(&sc[0][0], 0, sizeof(sc));
614 /* Fetch the current config */
615 CtdlIPC_putline(ipc, "CONF get");
616 CtdlIPC_getline(ipc, buf);
619 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
621 strcpy(&sc[a][0], buf);
626 /* Fetch the expire policy (this will silently fail on old servers,
627 * resulting in "default" policy)
629 CtdlIPC_putline(ipc, "GPEX site");
630 CtdlIPC_getline(ipc, buf);
632 expire_mode = extract_int(&buf[4], 0);
633 expire_value = extract_int(&buf[4], 1);
637 /* Identification parameters */
639 strprompt("Node name", &sc[0][0], 15);
640 strprompt("Fully qualified domain name", &sc[1][0], 63);
641 strprompt("Human readable node name", &sc[2][0], 20);
642 strprompt("Modem dialup number", &sc[3][0], 15);
643 strprompt("Geographic location of this system", &sc[12][0], 31);
644 strprompt("Name of system administrator", &sc[13][0], 25);
645 strprompt("Paginator prompt", &sc[10][0], 79);
647 /* Security parameters */
649 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
650 "Require registration for new users",
652 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
653 "Disable self-service user account creation",
655 strprompt("Initial access level for new users", &sc[6][0], 1);
656 strprompt("Access level required to create rooms", &sc[19][0], 1);
657 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
658 "Automatically give room aide privs to a user who creates a private room",
661 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
662 "Automatically move problem user messages to twit room",
665 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
666 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
667 "Restrict Internet mail to only those with that privilege",
669 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
670 "Allow Aides to Zap (forget) rooms",
672 snprintf(sc[30], sizeof sc[29], "%d", (boolprompt(
673 "Allow system Aides access to user mailboxes",
676 if (strlen(&sc[18][0]) > 0) logpages = 1;
678 logpages = boolprompt("Log all pages", logpages);
680 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
689 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
690 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
691 strprompt("Maximum message length", &sc[20][0], 20);
692 strprompt("Minimum number of worker threads", &sc[21][0], 3);
693 strprompt("Maximum number of worker threads", &sc[22][0], 3);
695 /* no longer applicable ... deprecated
696 strprompt("Server-to-server networking password", &sc[15][0], 19);
699 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
700 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
701 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
702 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
704 /* Expiry settings */
705 strprompt("Default user purge time (days)", &sc[16][0], 5);
706 strprompt("Default room purge time (days)", &sc[17][0], 5);
708 /* Angels and demons dancing in my head... */
710 snprintf(buf, sizeof buf, "%d", expire_mode);
711 strprompt("System default message expire policy (? for list)",
715 "1. Never automatically expire messages\n"
716 "2. Expire by message count\n"
717 "3. Expire by message age\n");
719 } while ((buf[0] < 49) || (buf[0] > 51));
720 expire_mode = buf[0] - 48;
722 /* ...lunatics and monsters underneath my bed */
723 if (expire_mode == 2) {
724 snprintf(buf, sizeof buf, "%d", expire_value);
725 strprompt("Keep how many messages online?", buf, 10);
726 expire_value = atol(buf);
728 if (expire_mode == 3) {
729 snprintf(buf, sizeof buf, "%d", expire_value);
730 strprompt("Keep messages for how many days?", buf, 10);
731 expire_value = atol(buf);
734 scr_printf("Save this configuration? ");
736 CtdlIPC_putline(ipc, "CONF set");
737 CtdlIPC_getline(ipc, buf);
739 for (a = 0; a < 31; ++a)
740 CtdlIPC_putline(ipc, &sc[a][0]);
741 CtdlIPC_putline(ipc, "000");
743 snprintf(buf, sizeof buf, "SPEX site|%d|%d",
744 expire_mode, expire_value);
745 CtdlIPC_putline(ipc, buf);
746 CtdlIPC_getline(ipc, buf);
752 * support function for do_internet_configuration()
754 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
757 keyopt(" <1> localhost (Alias for this computer)\n");
758 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
759 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
760 keyopt(" <4> directory (Consult the Global Address Book)\n");
761 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
762 sel = intprompt("Which one", 1, 1, 5);
764 case 1: strcpy(buf, "localhost");
766 case 2: strcpy(buf, "gatewaydomain");
768 case 3: strcpy(buf, "smarthost");
770 case 4: strcpy(buf, "directory");
772 case 5: strcpy(buf, "spamassassin");
779 * Internet mail configuration
781 void do_internet_configuration(CtdlIPC *ipc)
792 snprintf(buf, sizeof buf, "CONF getsys|%s", INTERNETCFG);
793 CtdlIPC_putline(ipc, buf);
794 CtdlIPC_getline(ipc, buf);
795 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
797 if (num_recs == 1) recs = malloc(sizeof(char *));
798 else recs = realloc(recs, (sizeof(char *)) * num_recs);
799 recs[num_recs-1] = malloc(SIZ);
800 strcpy(recs[num_recs-1], buf);
806 scr_printf("### Host or domain Record type \n");
808 scr_printf("--- -------------------------------------------------- --------------------\n");
809 for (i=0; i<num_recs; ++i) {
811 scr_printf("%3d ", i+1);
812 extract(buf, recs[i], 0);
814 scr_printf("%-50s ", buf);
815 extract(buf, recs[i], 1);
816 color(BRIGHT_MAGENTA);
817 scr_printf("%-20s\n", buf);
821 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
826 recs = malloc(sizeof(char *));
827 else recs = realloc(recs,
828 (sizeof(char *)) * num_recs);
829 newprompt("Enter host name: ",
832 get_inet_rec_type(ipc, &buf[strlen(buf)]);
833 recs[num_recs-1] = strdup(buf);
836 i = intprompt("Delete which one",
840 for (j=i; j<num_recs; ++j)
844 snprintf(buf, sizeof buf, "CONF putsys|%s",
846 CtdlIPC_putline(ipc, buf);
847 CtdlIPC_getline(ipc, buf);
849 for (i=0; i<num_recs; ++i) {
850 CtdlIPC_putline(ipc, recs[i]);
852 CtdlIPC_putline(ipc, "000");
855 scr_printf("%s\n", &buf[4]);
860 quitting = boolprompt(
861 "Quit without saving", 0);
866 } while (quitting == 0);
869 for (i=0; i<num_recs; ++i) free(recs[i]);
877 * Edit network configuration for room sharing, mailing lists, etc.
879 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
881 char filename[PATH_MAX];
882 char changefile[PATH_MAX];
893 if (strlen(editor_path) == 0) {
894 scr_printf("You must have an external editor configured in"
895 " order to use this function.\n");
899 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
900 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
902 tempfp = fopen(filename, "w");
903 if (tempfp == NULL) {
904 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
908 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
909 fprintf(tempfp, "# %s\n", comment);
910 fprintf(tempfp, "# Specify one per line.\n"
913 CtdlIPC_putline(ipc, "GNET");
914 CtdlIPC_getline(ipc, buf);
916 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
917 extract(instr, buf, 0);
918 if (!strcasecmp(instr, entrytype)) {
919 extract(addr, buf, 1);
920 fprintf(tempfp, "%s\n", addr);
926 e_ex_code = 1; /* start with a failed exit code */
928 cksum = file_checksum(filename);
929 if (editor_pid == 0) {
930 chmod(filename, 0600);
933 putenv("WINDOW_TITLE=Network configuration");
934 execlp(editor_path, editor_path, filename, NULL);
937 if (editor_pid > 0) {
940 b = ka_wait(&e_ex_code);
941 } while ((b != editor_pid) && (b >= 0));
947 if (file_checksum(filename) == cksum) {
948 err_printf("*** Not saving changes.\n");
952 if (e_ex_code == 0) { /* Save changes */
953 changefp = fopen(changefile, "w");
954 CtdlIPC_putline(ipc, "GNET");
955 CtdlIPC_getline(ipc, buf);
957 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
958 extract(instr, buf, 0);
959 if (strcasecmp(instr, entrytype)) {
960 fprintf(changefp, "%s\n", buf);
964 tempfp = fopen(filename, "r");
965 while (fgets(buf, sizeof buf, tempfp) != NULL) {
966 for (i=0; i<strlen(buf); ++i) {
967 if (buf[i] == '#') buf[i] = 0;
970 if (strlen(buf) > 0) {
971 fprintf(changefp, "%s|%s\n", entrytype, buf);
977 /* now write it to the server... */
978 CtdlIPC_putline(ipc, "SNET");
979 CtdlIPC_getline(ipc, buf);
981 changefp = fopen(changefile, "r");
982 if (changefp != NULL) {
983 while (fgets(buf, sizeof buf,
985 buf[strlen(buf) - 1] = 0;
986 CtdlIPC_putline(ipc, buf);
990 CtdlIPC_putline(ipc, "000");
994 unlink(filename); /* Delete the temporary files */
1000 * IGnet node configuration
1002 void do_ignet_configuration(CtdlIPC *ipc) {
1012 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1013 CtdlIPC_putline(ipc, buf);
1014 CtdlIPC_getline(ipc, buf);
1015 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1017 if (num_recs == 1) recs = malloc(sizeof(char *));
1018 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1019 recs[num_recs-1] = malloc(SIZ);
1020 strcpy(recs[num_recs-1], buf);
1025 color(BRIGHT_WHITE);
1034 "------------------ "
1035 "-------------------------------- "
1037 for (i=0; i<num_recs; ++i) {
1039 scr_printf("%3d ", i+1);
1040 extract(buf, recs[i], 0);
1042 scr_printf("%-16s ", buf);
1043 extract(buf, recs[i], 1);
1044 color(BRIGHT_MAGENTA);
1045 scr_printf("%-18s ", buf);
1046 extract(buf, recs[i], 2);
1048 scr_printf("%-32s ", buf);
1049 extract(buf, recs[i], 3);
1050 color(BRIGHT_MAGENTA);
1051 scr_printf("%-3s\n", buf);
1055 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1060 recs = malloc(sizeof(char *));
1061 else recs = realloc(recs,
1062 (sizeof(char *)) * num_recs);
1063 newprompt("Enter node name : ", buf, 16);
1065 newprompt("Enter shared secret: ",
1066 &buf[strlen(buf)], 18);
1068 newprompt("Enter host or IP : ",
1069 &buf[strlen(buf)], 32);
1070 strcat(buf, "|504");
1071 strprompt("Enter port number : ",
1072 &buf[strlen(buf)-3], 5);
1073 recs[num_recs-1] = strdup(buf);
1076 i = intprompt("Delete which one",
1077 1, 1, num_recs) - 1;
1080 for (j=i; j<num_recs; ++j)
1081 recs[j] = recs[j+1];
1084 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1085 CtdlIPC_putline(ipc, buf);
1086 CtdlIPC_getline(ipc, buf);
1087 if (buf[0] == '4') {
1088 for (i=0; i<num_recs; ++i) {
1089 CtdlIPC_putline(ipc, recs[i]);
1091 CtdlIPC_putline(ipc, "000");
1094 scr_printf("%s\n", &buf[4]);
1099 quitting = boolprompt(
1100 "Quit without saving", 0);
1105 } while (quitting == 0);
1108 for (i=0; i<num_recs; ++i) free(recs[i]);
1114 * Filter list configuration
1116 void do_filterlist_configuration(CtdlIPC *ipc)
1127 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1128 CtdlIPC_putline(ipc, buf);
1129 CtdlIPC_getline(ipc, buf);
1130 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1132 if (num_recs == 1) recs = malloc(sizeof(char *));
1133 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1134 recs[num_recs-1] = malloc(SIZ);
1135 strcpy(recs[num_recs-1], buf);
1140 color(BRIGHT_WHITE);
1148 "---------------------------- "
1149 "---------------------------- "
1152 for (i=0; i<num_recs; ++i) {
1154 scr_printf("%3d ", i+1);
1155 extract(buf, recs[i], 0);
1157 scr_printf("%-28s ", buf);
1158 extract(buf, recs[i], 1);
1159 color(BRIGHT_MAGENTA);
1160 scr_printf("%-28s ", buf);
1161 extract(buf, recs[i], 2);
1163 scr_printf("%-16s\n", buf);
1164 extract(buf, recs[i], 3);
1168 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1173 recs = malloc(sizeof(char *));
1174 else recs = realloc(recs,
1175 (sizeof(char *)) * num_recs);
1176 newprompt("Enter user name: ", buf, 28);
1178 newprompt("Enter room name: ",
1179 &buf[strlen(buf)], 28);
1181 newprompt("Enter node name: ",
1182 &buf[strlen(buf)], 16);
1184 recs[num_recs-1] = strdup(buf);
1187 i = intprompt("Delete which one",
1188 1, 1, num_recs) - 1;
1191 for (j=i; j<num_recs; ++j)
1192 recs[j] = recs[j+1];
1195 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1196 CtdlIPC_putline(ipc, buf);
1197 CtdlIPC_getline(ipc, buf);
1198 if (buf[0] == '4') {
1199 for (i=0; i<num_recs; ++i) {
1200 CtdlIPC_putline(ipc, recs[i]);
1202 CtdlIPC_putline(ipc, "000");
1205 scr_printf("%s\n", &buf[4]);
1210 quitting = boolprompt(
1211 "Quit without saving", 0);
1216 } while (quitting == 0);
1219 for (i=0; i<num_recs; ++i) free(recs[i]);