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>
35 #include "citadel_ipc.h"
36 #include "citadel_decls.h"
37 #include "routines2.h"
48 extern char tempdir[];
49 extern char *axdefs[7];
50 extern long highest_msg_read;
51 extern long maxmsgnum;
52 extern unsigned room_flags;
53 extern int screenwidth;
57 int eopen(char *name, int mode)
60 ret = open(name, mode);
62 err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
71 int room_prompt(unsigned int qrflags)
72 { /* return proper room prompt character */
75 if (qrflags & QR_DIRECTORY)
77 if ((a == ']') && (qrflags & QR_NETWORK))
79 if ((a == '>') && (qrflags & QR_NETWORK))
84 void entregis(CtdlIPC *ipc)
85 { /* register with name and address */
101 int r; /* IPC response code */
106 strcpy(tmpstate, "");
108 strcpy(tmpphone, "");
109 strcpy(tmpemail, "");
110 strcpy(tmpcountry, "");
112 r = CtdlIPCGetUserRegistration(ipc, NULL, ®, buf);
116 while (reg && strlen(reg) > 0) {
118 extract_token(buf, reg, 0, '\n');
119 remove_token(reg, 0, '\n');
122 strcpy(tmpname, buf);
124 strcpy(tmpaddr, buf);
126 strcpy(tmpcity, buf);
128 strcpy(tmpstate, buf);
132 strcpy(tmpphone, buf);
134 strcpy(tmpemail, buf);
136 strcpy(tmpcountry, buf);
140 strprompt("REAL name", tmpname, 29);
141 strprompt("Address", tmpaddr, 24);
142 strprompt("City/town", tmpcity, 14);
143 strprompt("State/province", tmpstate, 2);
144 strprompt("ZIP/Postal Code", tmpzip, 10);
145 strprompt("Country", tmpcountry, 31);
146 strprompt("Telephone number", tmpphone, 14);
150 strcpy(holdemail, tmpemail);
151 strprompt("Email address", tmpemail, 31);
152 r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
154 extract_token(diruser, buf, 0, '@');
155 extract_token(dirnode, buf, 1, '@');
158 if ((strcasecmp(diruser, fullname))
159 || (strcasecmp(dirnode, serv_info.serv_nodename))) {
161 "\nYou can't use %s as your address.\n",
164 "It is already in use by %s @ %s.\n",
167 strcpy(tmpemail, holdemail);
172 /* now send the registration info back to the server */
173 reg = (char *)realloc(reg, 4096); /* Overkill? */
175 sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
176 tmpname, tmpaddr, tmpcity, tmpstate,
177 tmpzip, tmpphone, tmpemail, tmpcountry);
178 r = CtdlIPCSetRegistration(ipc, reg, buf);
180 scr_printf("%s\n", buf);
186 void updatels(CtdlIPC *ipc)
187 { /* make all messages old in current room */
189 int r; /* IPC response code */
191 if (rc_alt_semantics) {
192 if (maxmsgnum == 0 && highest_msg_read == 0) {
195 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
196 maxmsgnum : highest_msg_read, buf);
198 r = CtdlIPCSetLastRead(ipc, maxmsgnum, buf);
201 scr_printf("%s\n", buf);
205 * only make messages old in this room that have been read
207 void updatelsa(CtdlIPC *ipc)
210 int r; /* IPC response code */
212 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
214 scr_printf("%s\n", &buf[4]);
219 * client-based uploads (for users with their own clientware)
221 void cli_upload(CtdlIPC *ipc)
227 int r; /* IPC response code */
231 if ((room_flags & QR_UPLOAD) == 0) {
232 scr_printf("*** You cannot upload to this room.\n");
235 newprompt("File to be uploaded: ", flnm, 55);
236 fd = open(flnm, O_RDONLY);
238 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
241 scr_printf("Enter a description of this file:\n");
242 newprompt(": ", desc, 75);
244 /* Keep generating filenames in hope of finding a unique one */
247 /* basename of filename */
249 if (haschar(tbuf, '/'))
250 strcpy(tbuf, strrchr(tbuf, '/'));
251 /* filename.1, filename.2, etc */
253 sprintf(buf + strlen(buf), ".%d", a);
256 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
257 if (r / 100 == 5 || r < 0)
258 scr_printf("%s\n", buf);
267 * Function used for various image upload commands
269 void cli_image_upload(CtdlIPC *ipc, char *keyname)
275 /* Can we upload this image? */
276 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
278 err_printf("%s\n", buf);
281 newprompt("Image file to be uploaded: ", flnm, 55);
282 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
284 err_printf("%s\n", buf);
286 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
288 /* else upload succeeded */
293 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
295 void upload(CtdlIPC *ipc, int c)
296 { /* c = upload mode */
306 if ((room_flags & QR_UPLOAD) == 0) {
307 scr_printf("*** You cannot upload to this room.\n");
310 /* we don't need a filename when receiving batch y/z modem */
311 if ((c == 2) || (c == 3))
314 newprompt("Enter filename: ", flnm, 15);
316 for (a = 0; a < strlen(flnm); ++a)
317 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
318 || (flnm[a] == '?') || (flnm[a] == '*')
319 || (flnm[a] == ';') || (flnm[a] == '&'))
322 /* create a temporary directory... */
323 if (mkdir(tempdir, 0700) != 0) {
324 scr_printf("*** Could not create temporary directory %s: %s\n",
325 tempdir, strerror(errno));
328 /* now do the transfer ... in a separate process */
335 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
336 fp = fopen(flnm, "w");
352 execlp("rx", "rx", flnm, NULL);
357 execlp("rb", "rb", NULL);
362 execlp("rz", "rz", NULL);
368 } while ((b != xfer_pid) && (b != (-1)));
373 scr_printf("\r*** Transfer unsuccessful.\n");
377 scr_printf("\r*** Transfer successful.\n");
378 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
379 lsfp = popen(buf, "r");
381 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
382 flnm[strlen(flnm) - 1] = 0; /* chop newline */
383 snprintf(buf, sizeof buf,
384 "Enter a short description of '%s':\n: ",
386 newprompt(buf, desc, 150);
387 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
388 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
389 scr_printf("%s\n", tbuf);
397 * validate a user (returns 0 for successful validation, nonzero if quitting)
399 int val_user(CtdlIPC *ipc, char *user, int do_validate)
407 int r; /* IPC response code */
410 r = CtdlIPCGetUserRegistration(ipc, user, &resp, cmd);
414 extract_token(buf, resp, 0, '\n');
415 remove_token(resp, 0, '\n');
418 scr_printf("User #%s - %s ", buf, cmd);
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 (strlen(resp));
440 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
442 scr_printf("%s\n%s\n", user, &cmd[4]);
444 if (resp) free(resp);
447 /* now set the access level */
449 sprintf(answer, "%d", ax);
450 strprompt("New access level (? for help, q to quit)",
452 if ((answer[0] >= '0') && (answer[0] <= '6')) {
454 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
456 scr_printf("%s\n\n", cmd);
459 if (tolower(answer[0]) == 'q') {
460 scr_printf("*** Aborted.\n\n");
463 if (answer[0] == '?') {
464 scr_printf("Available access levels:\n");
465 for (a=0; a<7; ++a) {
466 scr_printf("%d - %s\n",
476 void validate(CtdlIPC *ipc)
477 { /* validate new users */
481 int r; /* IPC response code */
484 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
488 scr_printf("%s\n", cmd);
490 extract(buf, cmd, 0);
491 if (val_user(ipc, buf, 1) != 0) finished = 1;
493 } while (finished == 0);
503 signal(SIGINT, SIG_DFL);
504 signal(SIGQUIT, SIG_DFL);
505 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
506 err_printf("Could not open a shell: %s\n", strerror(errno));
511 } while ((a != b) && (a != (-1)));
517 * <.A>ide <F>ile <D>elete command
519 void deletefile(CtdlIPC *ipc)
524 newprompt("Filename: ", filename, 31);
525 if (strlen(filename) == 0)
527 CtdlIPCDeleteFile(ipc, filename, buf);
528 err_printf("%s\n", buf);
532 * <.A>ide <F>ile <S>end command
534 void netsendfile(CtdlIPC *ipc)
536 char filename[32], destsys[20], buf[SIZ];
538 newprompt("Filename: ", filename, 31);
539 if (strlen(filename) == 0)
541 newprompt("System to send to: ", destsys, 19);
542 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
543 err_printf("%s\n", buf);
548 * <.A>ide <F>ile <M>ove command
550 void movefile(CtdlIPC *ipc)
553 char newroom[ROOMNAMELEN];
556 newprompt("Filename: ", filename, 63);
557 if (strlen(filename) == 0)
559 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
560 CtdlIPCMoveFile(ipc, filename, newroom, buf);
561 err_printf("%s\n", buf);
566 * list of users who have filled out a bio
568 void list_bio(CtdlIPC *ipc)
573 int r; /* IPC response code */
575 r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
577 pprintf("%s\n", buf);
580 while (strlen(resp)) {
581 extract_token(buf, resp, 0, '\n');
582 remove_token(resp, 0, '\n');
583 if ((pos + strlen(buf) + 5) > screenwidth) {
587 pprintf("%s, ", buf);
588 pos = pos + strlen(buf) + 2;
590 pprintf("%c%c \n\n", 8, 8);
591 if (resp) free(resp);
598 void read_bio(CtdlIPC *ipc)
603 int r; /* IPC response code */
606 newprompt("Read bio for who ('?' for list) : ", who, 25);
608 if (!strcmp(who, "?"))
610 } while (!strcmp(who, "?"));
612 r = CtdlIPCGetBio(ipc, who, &resp, buf);
614 pprintf("%s\n", buf);
617 while (strlen(resp)) {
618 extract_token(buf, resp, 0, '\n');
619 remove_token(resp, 0, '\n');
620 pprintf("%s\n", buf);
622 if (resp) free(resp);
627 * General system configuration command
629 void do_system_configuration(CtdlIPC *ipc)
634 struct ExpirePolicy *expirepolicy = NULL;
637 int r; /* IPC response code */
639 /* Clear out the config buffers */
640 memset(&sc[0][0], 0, sizeof(sc));
642 /* Fetch the current config */
643 r = CtdlIPCGetSystemConfig(ipc, &resp, buf);
646 while (strlen(resp)) {
647 extract_token(buf, resp, 0, '\n');
648 remove_token(resp, 0, '\n');
650 strcpy(&sc[a][0], buf);
655 if (resp) free(resp);
657 /* Fetch the expire policy (this will silently fail on old servers,
658 * resulting in "default" policy)
660 r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf);
662 /* Identification parameters */
664 strprompt("Node name", &sc[0][0], 15);
665 strprompt("Fully qualified domain name", &sc[1][0], 63);
666 strprompt("Human readable node name", &sc[2][0], 20);
667 strprompt("Modem dialup number", &sc[3][0], 15);
668 strprompt("Geographic location of this system", &sc[12][0], 31);
669 strprompt("Name of system administrator", &sc[13][0], 25);
670 strprompt("Paginator prompt", &sc[10][0], 79);
672 /* Security parameters */
674 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
675 "Require registration for new users",
677 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
678 "Disable self-service user account creation",
680 strprompt("Initial access level for new users", &sc[6][0], 1);
681 strprompt("Access level required to create rooms", &sc[19][0], 1);
682 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
683 "Automatically give room aide privs to a user who creates a private room",
686 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
687 "Automatically move problem user messages to twit room",
690 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
691 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
692 "Restrict Internet mail to only those with that privilege",
694 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
695 "Allow Aides to Zap (forget) rooms",
697 snprintf(sc[30], sizeof sc[30], "%d", (boolprompt(
698 "Allow system Aides access to user mailboxes",
701 if (strlen(&sc[18][0]) > 0) logpages = 1;
703 logpages = boolprompt("Log all pages", logpages);
705 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
714 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
715 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
716 strprompt("Maximum message length", &sc[20][0], 20);
717 strprompt("Minimum number of worker threads", &sc[21][0], 3);
718 strprompt("Maximum number of worker threads", &sc[22][0], 3);
720 /* no longer applicable ... deprecated
721 strprompt("Server-to-server networking password", &sc[15][0], 19);
724 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
725 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
726 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
727 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
729 /* This logic flips the question around, because it's one of those
730 * situations where 0=yes and 1=no
734 a = boolprompt("Correct forged From: lines during authenticated SMTP",
737 snprintf(sc[25], sizeof sc[25], "%d", a);
739 /* Expiry settings */
740 strprompt("Default user purge time (days)", &sc[16][0], 5);
741 strprompt("Default room purge time (days)", &sc[17][0], 5);
743 /* Angels and demons dancing in my head... */
745 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
746 strprompt("System default message expire policy (? for list)",
750 "1. Never automatically expire messages\n"
751 "2. Expire by message count\n"
752 "3. Expire by message age\n");
754 } while ((buf[0] < '1') || (buf[0] > '3'));
755 expirepolicy->expire_mode = buf[0] - '0';
757 /* ...lunatics and monsters underneath my bed */
758 if (expirepolicy->expire_mode == 2) {
759 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
760 strprompt("Keep how many messages online?", buf, 10);
761 expirepolicy->expire_value = atol(buf);
763 if (expirepolicy->expire_mode == 3) {
764 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
765 strprompt("Keep messages for how many days?", buf, 10);
766 expirepolicy->expire_value = atol(buf);
769 scr_printf("Save this configuration? ");
772 for (a = 0; a < 31; a++)
773 r += 1 + strlen(sc[a]);
774 resp = (char *)calloc(1, r);
776 err_printf("Can't save config - out of memory!\n");
779 for (a = 0; a < 31; a++) {
783 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
785 err_printf("%s\n", buf);
788 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
790 err_printf("%s\n", buf);
797 * support function for do_internet_configuration()
799 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
802 keyopt(" <1> localhost (Alias for this computer)\n");
803 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
804 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
805 keyopt(" <4> directory (Consult the Global Address Book)\n");
806 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
807 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
808 sel = intprompt("Which one", 1, 1, 6);
810 case 1: strcpy(buf, "localhost");
812 case 2: strcpy(buf, "gatewaydomain");
814 case 3: strcpy(buf, "smarthost");
816 case 4: strcpy(buf, "directory");
818 case 5: strcpy(buf, "spamassassin");
820 case 6: strcpy(buf, "rbl");
827 * Internet mail configuration
829 void do_internet_configuration(CtdlIPC *ipc)
841 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
843 while (strlen(resp)) {
844 extract_token(buf, resp, 0, '\n');
845 remove_token(resp, 0, '\n');
847 if (num_recs == 1) recs = malloc(sizeof(char *));
848 else recs = realloc(recs, (sizeof(char *)) * num_recs);
849 recs[num_recs-1] = malloc(strlen(buf) + 1);
850 strcpy(recs[num_recs-1], buf);
853 if (resp) free(resp);
858 scr_printf("### Host or domain Record type \n");
860 scr_printf("--- -------------------------------------------------- --------------------\n");
861 for (i=0; i<num_recs; ++i) {
863 scr_printf("%3d ", i+1);
864 extract(buf, recs[i], 0);
866 scr_printf("%-50s ", buf);
867 extract(buf, recs[i], 1);
868 color(BRIGHT_MAGENTA);
869 scr_printf("%-20s\n", buf);
873 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
876 newprompt("Enter host name: ",
879 if (strlen(buf) > 0) {
882 recs = malloc(sizeof(char *));
883 else recs = realloc(recs,
884 (sizeof(char *)) * num_recs);
886 get_inet_rec_type(ipc,
888 recs[num_recs-1] = strdup(buf);
892 i = intprompt("Delete which one",
896 for (j=i; j<num_recs; ++j)
901 for (i = 0; i < num_recs; i++)
902 r += 1 + strlen(recs[i]);
903 resp = (char *)calloc(1, r);
905 err_printf("Can't save config - out of memory!\n");
908 if (num_recs) for (i = 0; i < num_recs; i++) {
909 strcat(resp, recs[i]);
912 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
914 err_printf("%s\n", buf);
919 quitting = boolprompt(
920 "Quit without saving", 0);
925 } while (quitting == 0);
928 for (i=0; i<num_recs; ++i) free(recs[i]);
936 * Edit network configuration for room sharing, mailing lists, etc.
938 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
940 char filename[PATH_MAX];
941 char changefile[PATH_MAX];
952 if (strlen(editor_paths[0]) == 0) {
953 scr_printf("You must have an external editor configured in"
954 " order to use this function.\n");
958 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
959 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
961 tempfp = fopen(filename, "w");
962 if (tempfp == NULL) {
963 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
967 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
968 fprintf(tempfp, "# %s\n", comment);
969 fprintf(tempfp, "# Specify one per line.\n"
972 CtdlIPC_putline(ipc, "GNET");
973 CtdlIPC_getline(ipc, buf);
975 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
976 extract(instr, buf, 0);
977 if (!strcasecmp(instr, entrytype)) {
978 extract(addr, buf, 1);
979 fprintf(tempfp, "%s\n", addr);
985 e_ex_code = 1; /* start with a failed exit code */
989 cksum = file_checksum(filename);
990 if (editor_pid == 0) {
991 chmod(filename, 0600);
992 putenv("WINDOW_TITLE=Network configuration");
993 execlp(editor_paths[0], editor_paths[0], filename, NULL);
996 if (editor_pid > 0) {
999 b = ka_wait(&e_ex_code);
1000 } while ((b != editor_pid) && (b >= 0));
1006 if (file_checksum(filename) == cksum) {
1007 err_printf("*** Not saving changes.\n");
1011 if (e_ex_code == 0) { /* Save changes */
1012 changefp = fopen(changefile, "w");
1013 CtdlIPC_putline(ipc, "GNET");
1014 CtdlIPC_getline(ipc, buf);
1015 if (buf[0] == '1') {
1016 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1017 extract(instr, buf, 0);
1018 if (strcasecmp(instr, entrytype)) {
1019 fprintf(changefp, "%s\n", buf);
1023 tempfp = fopen(filename, "r");
1024 while (fgets(buf, sizeof buf, tempfp) != NULL) {
1025 for (i=0; i<strlen(buf); ++i) {
1026 if (buf[i] == '#') buf[i] = 0;
1029 if (strlen(buf) > 0) {
1030 fprintf(changefp, "%s|%s\n", entrytype, buf);
1036 /* now write it to the server... */
1037 CtdlIPC_putline(ipc, "SNET");
1038 CtdlIPC_getline(ipc, buf);
1039 if (buf[0] == '4') {
1040 changefp = fopen(changefile, "r");
1041 if (changefp != NULL) {
1042 while (fgets(buf, sizeof buf,
1043 changefp) != NULL) {
1044 buf[strlen(buf) - 1] = 0;
1045 CtdlIPC_putline(ipc, buf);
1049 CtdlIPC_putline(ipc, "000");
1053 unlink(filename); /* Delete the temporary files */
1059 * IGnet node configuration
1061 void do_ignet_configuration(CtdlIPC *ipc) {
1071 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1072 CtdlIPC_putline(ipc, buf);
1073 CtdlIPC_getline(ipc, buf);
1074 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1076 if (num_recs == 1) recs = malloc(sizeof(char *));
1077 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1078 recs[num_recs-1] = malloc(SIZ);
1079 strcpy(recs[num_recs-1], buf);
1084 color(BRIGHT_WHITE);
1093 "------------------ "
1094 "-------------------------------- "
1096 for (i=0; i<num_recs; ++i) {
1098 scr_printf("%3d ", i+1);
1099 extract(buf, recs[i], 0);
1101 scr_printf("%-16s ", buf);
1102 extract(buf, recs[i], 1);
1103 color(BRIGHT_MAGENTA);
1104 scr_printf("%-18s ", buf);
1105 extract(buf, recs[i], 2);
1107 scr_printf("%-32s ", buf);
1108 extract(buf, recs[i], 3);
1109 color(BRIGHT_MAGENTA);
1110 scr_printf("%-3s\n", buf);
1114 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1119 recs = malloc(sizeof(char *));
1120 else recs = realloc(recs,
1121 (sizeof(char *)) * num_recs);
1122 newprompt("Enter node name : ", buf, 16);
1124 newprompt("Enter shared secret: ",
1125 &buf[strlen(buf)], 18);
1127 newprompt("Enter host or IP : ",
1128 &buf[strlen(buf)], 32);
1129 strcat(buf, "|504");
1130 strprompt("Enter port number : ",
1131 &buf[strlen(buf)-3], 5);
1132 recs[num_recs-1] = strdup(buf);
1135 i = intprompt("Delete which one",
1136 1, 1, num_recs) - 1;
1139 for (j=i; j<num_recs; ++j)
1140 recs[j] = recs[j+1];
1143 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1144 CtdlIPC_putline(ipc, buf);
1145 CtdlIPC_getline(ipc, buf);
1146 if (buf[0] == '4') {
1147 for (i=0; i<num_recs; ++i) {
1148 CtdlIPC_putline(ipc, recs[i]);
1150 CtdlIPC_putline(ipc, "000");
1153 scr_printf("%s\n", &buf[4]);
1158 quitting = boolprompt(
1159 "Quit without saving", 0);
1164 } while (quitting == 0);
1167 for (i=0; i<num_recs; ++i) free(recs[i]);
1173 * Filter list configuration
1175 void do_filterlist_configuration(CtdlIPC *ipc)
1186 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1187 CtdlIPC_putline(ipc, buf);
1188 CtdlIPC_getline(ipc, buf);
1189 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1191 if (num_recs == 1) recs = malloc(sizeof(char *));
1192 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1193 recs[num_recs-1] = malloc(SIZ);
1194 strcpy(recs[num_recs-1], buf);
1199 color(BRIGHT_WHITE);
1207 "---------------------------- "
1208 "---------------------------- "
1211 for (i=0; i<num_recs; ++i) {
1213 scr_printf("%3d ", i+1);
1214 extract(buf, recs[i], 0);
1216 scr_printf("%-28s ", buf);
1217 extract(buf, recs[i], 1);
1218 color(BRIGHT_MAGENTA);
1219 scr_printf("%-28s ", buf);
1220 extract(buf, recs[i], 2);
1222 scr_printf("%-16s\n", buf);
1223 extract(buf, recs[i], 3);
1227 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1232 recs = malloc(sizeof(char *));
1233 else recs = realloc(recs,
1234 (sizeof(char *)) * num_recs);
1235 newprompt("Enter user name: ", buf, 28);
1237 newprompt("Enter room name: ",
1238 &buf[strlen(buf)], 28);
1240 newprompt("Enter node name: ",
1241 &buf[strlen(buf)], 16);
1243 recs[num_recs-1] = strdup(buf);
1246 i = intprompt("Delete which one",
1247 1, 1, num_recs) - 1;
1250 for (j=i; j<num_recs; ++j)
1251 recs[j] = recs[j+1];
1254 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1255 CtdlIPC_putline(ipc, buf);
1256 CtdlIPC_getline(ipc, buf);
1257 if (buf[0] == '4') {
1258 for (i=0; i<num_recs; ++i) {
1259 CtdlIPC_putline(ipc, recs[i]);
1261 CtdlIPC_putline(ipc, "000");
1264 scr_printf("%s\n", &buf[4]);
1269 quitting = boolprompt(
1270 "Quit without saving", 0);
1275 } while (quitting == 0);
1278 for (i=0; i<num_recs; ++i) free(recs[i]);