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 > highest_msg_read) ?
199 maxmsgnum : highest_msg_read, buf);
200 /* r = CtdlIPCSetLastRead(ipc, maxmsgnum, buf); */
201 /* This is a quick-and-dirty fix to all msgs becoming new in Mail>.
202 * It will need to be rethought when messages.c is rewritten.
206 scr_printf("%s\n", buf);
210 * only make messages old in this room that have been read
212 void updatelsa(CtdlIPC *ipc)
215 int r; /* IPC response code */
217 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
219 scr_printf("%s\n", &buf[4]);
224 * client-based uploads (for users with their own clientware)
226 void cli_upload(CtdlIPC *ipc)
232 int r; /* IPC response code */
236 if ((room_flags & QR_UPLOAD) == 0) {
237 scr_printf("*** You cannot upload to this room.\n");
240 newprompt("File to be uploaded: ", flnm, 55);
241 fd = open(flnm, O_RDONLY);
243 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
246 scr_printf("Enter a description of this file:\n");
247 newprompt(": ", desc, 75);
249 /* Keep generating filenames in hope of finding a unique one */
252 /* basename of filename */
254 if (haschar(tbuf, '/'))
255 strcpy(tbuf, strrchr(tbuf, '/'));
256 /* filename.1, filename.2, etc */
258 sprintf(buf + strlen(buf), ".%d", a);
261 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
262 if (r / 100 == 5 || r < 0)
263 scr_printf("%s\n", buf);
272 * Function used for various image upload commands
274 void cli_image_upload(CtdlIPC *ipc, char *keyname)
280 /* Can we upload this image? */
281 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
283 err_printf("%s\n", buf);
286 newprompt("Image file to be uploaded: ", flnm, 55);
287 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
289 err_printf("%s\n", buf);
291 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
293 /* else upload succeeded */
298 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
300 void upload(CtdlIPC *ipc, int c)
301 { /* c = upload mode */
311 if ((room_flags & QR_UPLOAD) == 0) {
312 scr_printf("*** You cannot upload to this room.\n");
315 /* we don't need a filename when receiving batch y/z modem */
316 if ((c == 2) || (c == 3))
319 newprompt("Enter filename: ", flnm, 15);
321 for (a = 0; a < strlen(flnm); ++a)
322 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
323 || (flnm[a] == '?') || (flnm[a] == '*')
324 || (flnm[a] == ';') || (flnm[a] == '&'))
327 /* create a temporary directory... */
328 if (mkdir(tempdir, 0700) != 0) {
329 scr_printf("*** Could not create temporary directory %s: %s\n",
330 tempdir, strerror(errno));
333 /* now do the transfer ... in a separate process */
340 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
341 fp = fopen(flnm, "w");
357 execlp("rx", "rx", flnm, NULL);
362 execlp("rb", "rb", NULL);
367 execlp("rz", "rz", NULL);
373 } while ((b != xfer_pid) && (b != (-1)));
378 scr_printf("\r*** Transfer unsuccessful.\n");
382 scr_printf("\r*** Transfer successful.\n");
383 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
384 lsfp = popen(buf, "r");
386 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
387 flnm[strlen(flnm) - 1] = 0; /* chop newline */
388 snprintf(buf, sizeof buf,
389 "Enter a short description of '%s':\n: ",
391 newprompt(buf, desc, 150);
392 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
393 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
394 scr_printf("%s\n", tbuf);
402 * validate a user (returns 0 for successful validation, nonzero if quitting)
404 int val_user(CtdlIPC *ipc, char *user, int do_validate)
412 int r; /* IPC response code */
415 r = CtdlIPCGetUserRegistration(ipc, user, &resp, cmd);
419 extract_token(buf, resp, 0, '\n');
420 remove_token(resp, 0, '\n');
423 scr_printf("User #%s - %s ", buf, cmd);
425 scr_printf("PW: %s\n", buf);
427 scr_printf("%s\n", buf);
429 scr_printf("%s\n", buf);
431 scr_printf("%s, ", buf);
433 scr_printf("%s ", buf);
435 scr_printf("%s\n", buf);
437 scr_printf("%s\n", buf);
441 scr_printf("%s\n", buf);
443 scr_printf("%s\n", buf);
444 } while (strlen(resp));
445 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
447 scr_printf("%s\n%s\n", user, &cmd[4]);
449 if (resp) free(resp);
452 /* now set the access level */
454 sprintf(answer, "%d", ax);
455 strprompt("New access level (? for help, q to quit)",
457 if ((answer[0] >= '0') && (answer[0] <= '6')) {
459 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
461 scr_printf("%s\n\n", cmd);
464 if (tolower(answer[0]) == 'q') {
465 scr_printf("*** Aborted.\n\n");
468 if (answer[0] == '?') {
469 scr_printf("Available access levels:\n");
470 for (a=0; a<7; ++a) {
471 scr_printf("%d - %s\n",
481 void validate(CtdlIPC *ipc)
482 { /* validate new users */
486 int r; /* IPC response code */
489 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
493 scr_printf("%s\n", cmd);
495 extract(buf, cmd, 0);
496 if (val_user(ipc, buf, 1) != 0) finished = 1;
498 } while (finished == 0);
508 signal(SIGINT, SIG_DFL);
509 signal(SIGQUIT, SIG_DFL);
510 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
511 err_printf("Could not open a shell: %s\n", strerror(errno));
516 } while ((a != b) && (a != (-1)));
522 * <.A>ide <F>ile <D>elete command
524 void deletefile(CtdlIPC *ipc)
529 newprompt("Filename: ", filename, 31);
530 if (strlen(filename) == 0)
532 CtdlIPCDeleteFile(ipc, filename, buf);
533 err_printf("%s\n", buf);
537 * <.A>ide <F>ile <S>end command
539 void netsendfile(CtdlIPC *ipc)
541 char filename[32], destsys[20], buf[SIZ];
543 newprompt("Filename: ", filename, 31);
544 if (strlen(filename) == 0)
546 newprompt("System to send to: ", destsys, 19);
547 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
548 err_printf("%s\n", buf);
553 * <.A>ide <F>ile <M>ove command
555 void movefile(CtdlIPC *ipc)
558 char newroom[ROOMNAMELEN];
561 newprompt("Filename: ", filename, 63);
562 if (strlen(filename) == 0)
564 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
565 CtdlIPCMoveFile(ipc, filename, newroom, buf);
566 err_printf("%s\n", buf);
571 * list of users who have filled out a bio
573 void list_bio(CtdlIPC *ipc)
578 int r; /* IPC response code */
580 r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
582 pprintf("%s\n", buf);
585 while (strlen(resp)) {
586 extract_token(buf, resp, 0, '\n');
587 remove_token(resp, 0, '\n');
588 if ((pos + strlen(buf) + 5) > screenwidth) {
592 pprintf("%s, ", buf);
593 pos = pos + strlen(buf) + 2;
595 pprintf("%c%c \n\n", 8, 8);
596 if (resp) free(resp);
603 void read_bio(CtdlIPC *ipc)
608 int r; /* IPC response code */
611 newprompt("Read bio for who ('?' for list) : ", who, 25);
613 if (!strcmp(who, "?"))
615 } while (!strcmp(who, "?"));
617 r = CtdlIPCGetBio(ipc, who, &resp, buf);
619 pprintf("%s\n", buf);
622 while (strlen(resp)) {
623 extract_token(buf, resp, 0, '\n');
624 remove_token(resp, 0, '\n');
625 pprintf("%s\n", buf);
627 if (resp) free(resp);
632 * General system configuration command
634 void do_system_configuration(CtdlIPC *ipc)
639 struct ExpirePolicy *expirepolicy = NULL;
642 int r; /* IPC response code */
644 /* Clear out the config buffers */
645 memset(&sc[0][0], 0, sizeof(sc));
647 /* Fetch the current config */
648 r = CtdlIPCGetSystemConfig(ipc, &resp, buf);
651 while (strlen(resp)) {
652 extract_token(buf, resp, 0, '\n');
653 remove_token(resp, 0, '\n');
655 strcpy(&sc[a][0], buf);
660 if (resp) free(resp);
662 /* Fetch the expire policy (this will silently fail on old servers,
663 * resulting in "default" policy)
665 r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf);
667 /* Identification parameters */
669 strprompt("Node name", &sc[0][0], 15);
670 strprompt("Fully qualified domain name", &sc[1][0], 63);
671 strprompt("Human readable node name", &sc[2][0], 20);
672 strprompt("Modem dialup number", &sc[3][0], 15);
673 strprompt("Geographic location of this system", &sc[12][0], 31);
674 strprompt("Name of system administrator", &sc[13][0], 25);
675 strprompt("Paginator prompt", &sc[10][0], 79);
677 /* Security parameters */
679 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
680 "Require registration for new users",
682 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
683 "Disable self-service user account creation",
685 strprompt("Initial access level for new users", &sc[6][0], 1);
686 strprompt("Access level required to create rooms", &sc[19][0], 1);
687 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
688 "Automatically give room aide privs to a user who creates a private room",
691 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
692 "Automatically move problem user messages to twit room",
695 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
696 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
697 "Restrict Internet mail to only those with that privilege",
699 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
700 "Allow Aides to Zap (forget) rooms",
702 snprintf(sc[30], sizeof sc[30], "%d", (boolprompt(
703 "Allow system Aides access to user mailboxes",
706 if (strlen(&sc[18][0]) > 0) logpages = 1;
708 logpages = boolprompt("Log all pages", logpages);
710 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
719 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
720 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
721 strprompt("Maximum message length", &sc[20][0], 20);
722 strprompt("Minimum number of worker threads", &sc[21][0], 3);
723 strprompt("Maximum number of worker threads", &sc[22][0], 3);
725 /* no longer applicable ... deprecated
726 strprompt("Server-to-server networking password", &sc[15][0], 19);
729 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
730 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
731 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
732 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
734 /* This logic flips the question around, because it's one of those
735 * situations where 0=yes and 1=no
739 a = boolprompt("Correct forged From: lines during authenticated SMTP",
742 snprintf(sc[25], sizeof sc[25], "%d", a);
744 /* Expiry settings */
745 strprompt("Default user purge time (days)", &sc[16][0], 5);
746 strprompt("Default room purge time (days)", &sc[17][0], 5);
748 /* Angels and demons dancing in my head... */
750 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
751 strprompt("System default message expire policy (? for list)",
755 "1. Never automatically expire messages\n"
756 "2. Expire by message count\n"
757 "3. Expire by message age\n");
759 } while ((buf[0] < '1') || (buf[0] > '3'));
760 expirepolicy->expire_mode = buf[0] - '0';
762 /* ...lunatics and monsters underneath my bed */
763 if (expirepolicy->expire_mode == 2) {
764 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
765 strprompt("Keep how many messages online?", buf, 10);
766 expirepolicy->expire_value = atol(buf);
768 if (expirepolicy->expire_mode == 3) {
769 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
770 strprompt("Keep messages for how many days?", buf, 10);
771 expirepolicy->expire_value = atol(buf);
774 scr_printf("Save this configuration? ");
777 for (a = 0; a < 31; a++)
778 r += 1 + strlen(sc[a]);
779 resp = (char *)calloc(1, r);
781 err_printf("Can't save config - out of memory!\n");
784 for (a = 0; a < 31; a++) {
788 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
790 err_printf("%s\n", buf);
793 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
795 err_printf("%s\n", buf);
802 * support function for do_internet_configuration()
804 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
807 keyopt(" <1> localhost (Alias for this computer)\n");
808 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
809 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
810 keyopt(" <4> directory (Consult the Global Address Book)\n");
811 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
812 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
813 sel = intprompt("Which one", 1, 1, 6);
815 case 1: strcpy(buf, "localhost");
817 case 2: strcpy(buf, "gatewaydomain");
819 case 3: strcpy(buf, "smarthost");
821 case 4: strcpy(buf, "directory");
823 case 5: strcpy(buf, "spamassassin");
825 case 6: strcpy(buf, "rbl");
832 * Internet mail configuration
834 void do_internet_configuration(CtdlIPC *ipc)
846 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
848 while (strlen(resp)) {
849 extract_token(buf, resp, 0, '\n');
850 remove_token(resp, 0, '\n');
852 if (num_recs == 1) recs = malloc(sizeof(char *));
853 else recs = realloc(recs, (sizeof(char *)) * num_recs);
854 recs[num_recs-1] = malloc(strlen(buf) + 1);
855 strcpy(recs[num_recs-1], buf);
858 if (resp) free(resp);
863 scr_printf("### Host or domain Record type \n");
865 scr_printf("--- -------------------------------------------------- --------------------\n");
866 for (i=0; i<num_recs; ++i) {
868 scr_printf("%3d ", i+1);
869 extract(buf, recs[i], 0);
871 scr_printf("%-50s ", buf);
872 extract(buf, recs[i], 1);
873 color(BRIGHT_MAGENTA);
874 scr_printf("%-20s\n", buf);
878 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
881 newprompt("Enter host name: ",
884 if (strlen(buf) > 0) {
887 recs = malloc(sizeof(char *));
888 else recs = realloc(recs,
889 (sizeof(char *)) * num_recs);
891 get_inet_rec_type(ipc,
893 recs[num_recs-1] = strdup(buf);
897 i = intprompt("Delete which one",
901 for (j=i; j<num_recs; ++j)
906 for (i = 0; i < num_recs; i++)
907 r += 1 + strlen(recs[i]);
908 resp = (char *)calloc(1, r);
910 err_printf("Can't save config - out of memory!\n");
913 if (num_recs) for (i = 0; i < num_recs; i++) {
914 strcat(resp, recs[i]);
917 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
919 err_printf("%s\n", buf);
924 quitting = boolprompt(
925 "Quit without saving", 0);
930 } while (quitting == 0);
933 for (i=0; i<num_recs; ++i) free(recs[i]);
941 * Edit network configuration for room sharing, mailing lists, etc.
943 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
945 char filename[PATH_MAX];
946 char changefile[PATH_MAX];
957 if (strlen(editor_paths[0]) == 0) {
958 scr_printf("You must have an external editor configured in"
959 " order to use this function.\n");
963 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
964 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
966 tempfp = fopen(filename, "w");
967 if (tempfp == NULL) {
968 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
972 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
973 fprintf(tempfp, "# %s\n", comment);
974 fprintf(tempfp, "# Specify one per line.\n"
977 CtdlIPC_putline(ipc, "GNET");
978 CtdlIPC_getline(ipc, buf);
980 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
981 extract(instr, buf, 0);
982 if (!strcasecmp(instr, entrytype)) {
983 extract(addr, buf, 1);
984 fprintf(tempfp, "%s\n", addr);
990 e_ex_code = 1; /* start with a failed exit code */
994 cksum = file_checksum(filename);
995 if (editor_pid == 0) {
996 chmod(filename, 0600);
997 putenv("WINDOW_TITLE=Network configuration");
998 execlp(editor_paths[0], editor_paths[0], filename, NULL);
1001 if (editor_pid > 0) {
1004 b = ka_wait(&e_ex_code);
1005 } while ((b != editor_pid) && (b >= 0));
1011 if (file_checksum(filename) == cksum) {
1012 err_printf("*** Not saving changes.\n");
1016 if (e_ex_code == 0) { /* Save changes */
1017 changefp = fopen(changefile, "w");
1018 CtdlIPC_putline(ipc, "GNET");
1019 CtdlIPC_getline(ipc, buf);
1020 if (buf[0] == '1') {
1021 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1022 extract(instr, buf, 0);
1023 if (strcasecmp(instr, entrytype)) {
1024 fprintf(changefp, "%s\n", buf);
1028 tempfp = fopen(filename, "r");
1029 while (fgets(buf, sizeof buf, tempfp) != NULL) {
1030 for (i=0; i<strlen(buf); ++i) {
1031 if (buf[i] == '#') buf[i] = 0;
1034 if (strlen(buf) > 0) {
1035 fprintf(changefp, "%s|%s\n", entrytype, buf);
1041 /* now write it to the server... */
1042 CtdlIPC_putline(ipc, "SNET");
1043 CtdlIPC_getline(ipc, buf);
1044 if (buf[0] == '4') {
1045 changefp = fopen(changefile, "r");
1046 if (changefp != NULL) {
1047 while (fgets(buf, sizeof buf,
1048 changefp) != NULL) {
1049 buf[strlen(buf) - 1] = 0;
1050 CtdlIPC_putline(ipc, buf);
1054 CtdlIPC_putline(ipc, "000");
1058 unlink(filename); /* Delete the temporary files */
1064 * IGnet node configuration
1066 void do_ignet_configuration(CtdlIPC *ipc) {
1076 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1077 CtdlIPC_putline(ipc, buf);
1078 CtdlIPC_getline(ipc, buf);
1079 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1081 if (num_recs == 1) recs = malloc(sizeof(char *));
1082 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1083 recs[num_recs-1] = malloc(SIZ);
1084 strcpy(recs[num_recs-1], buf);
1089 color(BRIGHT_WHITE);
1098 "------------------ "
1099 "-------------------------------- "
1101 for (i=0; i<num_recs; ++i) {
1103 scr_printf("%3d ", i+1);
1104 extract(buf, recs[i], 0);
1106 scr_printf("%-16s ", buf);
1107 extract(buf, recs[i], 1);
1108 color(BRIGHT_MAGENTA);
1109 scr_printf("%-18s ", buf);
1110 extract(buf, recs[i], 2);
1112 scr_printf("%-32s ", buf);
1113 extract(buf, recs[i], 3);
1114 color(BRIGHT_MAGENTA);
1115 scr_printf("%-3s\n", buf);
1119 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1124 recs = malloc(sizeof(char *));
1125 else recs = realloc(recs,
1126 (sizeof(char *)) * num_recs);
1127 newprompt("Enter node name : ", buf, 16);
1129 newprompt("Enter shared secret: ",
1130 &buf[strlen(buf)], 18);
1132 newprompt("Enter host or IP : ",
1133 &buf[strlen(buf)], 32);
1134 strcat(buf, "|504");
1135 strprompt("Enter port number : ",
1136 &buf[strlen(buf)-3], 5);
1137 recs[num_recs-1] = strdup(buf);
1140 i = intprompt("Delete which one",
1141 1, 1, num_recs) - 1;
1144 for (j=i; j<num_recs; ++j)
1145 recs[j] = recs[j+1];
1148 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1149 CtdlIPC_putline(ipc, buf);
1150 CtdlIPC_getline(ipc, buf);
1151 if (buf[0] == '4') {
1152 for (i=0; i<num_recs; ++i) {
1153 CtdlIPC_putline(ipc, recs[i]);
1155 CtdlIPC_putline(ipc, "000");
1158 scr_printf("%s\n", &buf[4]);
1163 quitting = boolprompt(
1164 "Quit without saving", 0);
1169 } while (quitting == 0);
1172 for (i=0; i<num_recs; ++i) free(recs[i]);
1178 * Filter list configuration
1180 void do_filterlist_configuration(CtdlIPC *ipc)
1191 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1192 CtdlIPC_putline(ipc, buf);
1193 CtdlIPC_getline(ipc, buf);
1194 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1196 if (num_recs == 1) recs = malloc(sizeof(char *));
1197 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1198 recs[num_recs-1] = malloc(SIZ);
1199 strcpy(recs[num_recs-1], buf);
1204 color(BRIGHT_WHITE);
1212 "---------------------------- "
1213 "---------------------------- "
1216 for (i=0; i<num_recs; ++i) {
1218 scr_printf("%3d ", i+1);
1219 extract(buf, recs[i], 0);
1221 scr_printf("%-28s ", buf);
1222 extract(buf, recs[i], 1);
1223 color(BRIGHT_MAGENTA);
1224 scr_printf("%-28s ", buf);
1225 extract(buf, recs[i], 2);
1227 scr_printf("%-16s\n", buf);
1228 extract(buf, recs[i], 3);
1232 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1237 recs = malloc(sizeof(char *));
1238 else recs = realloc(recs,
1239 (sizeof(char *)) * num_recs);
1240 newprompt("Enter user name: ", buf, 28);
1242 newprompt("Enter room name: ",
1243 &buf[strlen(buf)], 28);
1245 newprompt("Enter node name: ",
1246 &buf[strlen(buf)], 16);
1248 recs[num_recs-1] = strdup(buf);
1251 i = intprompt("Delete which one",
1252 1, 1, num_recs) - 1;
1255 for (j=i; j<num_recs; ++j)
1256 recs[j] = recs[j+1];
1259 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1260 CtdlIPC_putline(ipc, buf);
1261 CtdlIPC_getline(ipc, buf);
1262 if (buf[0] == '4') {
1263 for (i=0; i<num_recs; ++i) {
1264 CtdlIPC_putline(ipc, recs[i]);
1266 CtdlIPC_putline(ipc, "000");
1269 scr_printf("%s\n", &buf[4]);
1274 quitting = boolprompt(
1275 "Quit without saving", 0);
1280 } while (quitting == 0);
1283 for (i=0; i<num_recs; ++i) free(recs[i]);