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[29], "%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("SMTP server port (-1 to disable)", &sc[24][0], 5);
726 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
727 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
729 /* Expiry settings */
730 strprompt("Default user purge time (days)", &sc[16][0], 5);
731 strprompt("Default room purge time (days)", &sc[17][0], 5);
733 /* Angels and demons dancing in my head... */
735 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
736 strprompt("System default message expire policy (? for list)",
740 "1. Never automatically expire messages\n"
741 "2. Expire by message count\n"
742 "3. Expire by message age\n");
744 } while ((buf[0] < '1') || (buf[0] > '3'));
745 expirepolicy->expire_mode = buf[0] - '0';
747 /* ...lunatics and monsters underneath my bed */
748 if (expirepolicy->expire_mode == 2) {
749 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
750 strprompt("Keep how many messages online?", buf, 10);
751 expirepolicy->expire_value = atol(buf);
753 if (expirepolicy->expire_mode == 3) {
754 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
755 strprompt("Keep messages for how many days?", buf, 10);
756 expirepolicy->expire_value = atol(buf);
759 scr_printf("Save this configuration? ");
762 for (a = 0; a < 31; a++)
763 r += 1 + strlen(sc[a]);
764 resp = (char *)calloc(1, r);
766 err_printf("Can't save config - out of memory!\n");
769 for (a = 0; a < 31; a++) {
773 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
775 err_printf("%s\n", buf);
778 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
780 err_printf("%s\n", buf);
787 * support function for do_internet_configuration()
789 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
792 keyopt(" <1> localhost (Alias for this computer)\n");
793 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
794 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
795 keyopt(" <4> directory (Consult the Global Address Book)\n");
796 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
797 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
798 sel = intprompt("Which one", 1, 1, 6);
800 case 1: strcpy(buf, "localhost");
802 case 2: strcpy(buf, "gatewaydomain");
804 case 3: strcpy(buf, "smarthost");
806 case 4: strcpy(buf, "directory");
808 case 5: strcpy(buf, "spamassassin");
810 case 6: strcpy(buf, "rbl");
817 * Internet mail configuration
819 void do_internet_configuration(CtdlIPC *ipc)
831 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
833 while (strlen(resp)) {
834 extract_token(buf, resp, 0, '\n');
835 remove_token(resp, 0, '\n');
837 if (num_recs == 1) recs = malloc(sizeof(char *));
838 else recs = realloc(recs, (sizeof(char *)) * num_recs);
839 recs[num_recs-1] = malloc(strlen(buf) + 1);
840 strcpy(recs[num_recs-1], buf);
843 if (resp) free(resp);
848 scr_printf("### Host or domain Record type \n");
850 scr_printf("--- -------------------------------------------------- --------------------\n");
851 for (i=0; i<num_recs; ++i) {
853 scr_printf("%3d ", i+1);
854 extract(buf, recs[i], 0);
856 scr_printf("%-50s ", buf);
857 extract(buf, recs[i], 1);
858 color(BRIGHT_MAGENTA);
859 scr_printf("%-20s\n", buf);
863 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
866 newprompt("Enter host name: ",
869 if (strlen(buf) > 0) {
872 recs = malloc(sizeof(char *));
873 else recs = realloc(recs,
874 (sizeof(char *)) * num_recs);
876 get_inet_rec_type(ipc,
878 recs[num_recs-1] = strdup(buf);
882 i = intprompt("Delete which one",
886 for (j=i; j<num_recs; ++j)
891 for (i = 0; i < num_recs; i++)
892 r += 1 + strlen(recs[i]);
893 resp = (char *)calloc(1, r);
895 err_printf("Can't save config - out of memory!\n");
898 if (num_recs) for (i = 0; i < num_recs; i++) {
899 strcat(resp, recs[i]);
902 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
904 err_printf("%s\n", buf);
909 quitting = boolprompt(
910 "Quit without saving", 0);
915 } while (quitting == 0);
918 for (i=0; i<num_recs; ++i) free(recs[i]);
926 * Edit network configuration for room sharing, mailing lists, etc.
928 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
930 char filename[PATH_MAX];
931 char changefile[PATH_MAX];
942 if (strlen(editor_paths[0]) == 0) {
943 scr_printf("You must have an external editor configured in"
944 " order to use this function.\n");
948 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
949 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
951 tempfp = fopen(filename, "w");
952 if (tempfp == NULL) {
953 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
957 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
958 fprintf(tempfp, "# %s\n", comment);
959 fprintf(tempfp, "# Specify one per line.\n"
962 CtdlIPC_putline(ipc, "GNET");
963 CtdlIPC_getline(ipc, buf);
965 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
966 extract(instr, buf, 0);
967 if (!strcasecmp(instr, entrytype)) {
968 extract(addr, buf, 1);
969 fprintf(tempfp, "%s\n", addr);
975 e_ex_code = 1; /* start with a failed exit code */
979 cksum = file_checksum(filename);
980 if (editor_pid == 0) {
981 chmod(filename, 0600);
982 putenv("WINDOW_TITLE=Network configuration");
983 execlp(editor_paths[0], editor_paths[0], filename, NULL);
986 if (editor_pid > 0) {
989 b = ka_wait(&e_ex_code);
990 } while ((b != editor_pid) && (b >= 0));
996 if (file_checksum(filename) == cksum) {
997 err_printf("*** Not saving changes.\n");
1001 if (e_ex_code == 0) { /* Save changes */
1002 changefp = fopen(changefile, "w");
1003 CtdlIPC_putline(ipc, "GNET");
1004 CtdlIPC_getline(ipc, buf);
1005 if (buf[0] == '1') {
1006 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1007 extract(instr, buf, 0);
1008 if (strcasecmp(instr, entrytype)) {
1009 fprintf(changefp, "%s\n", buf);
1013 tempfp = fopen(filename, "r");
1014 while (fgets(buf, sizeof buf, tempfp) != NULL) {
1015 for (i=0; i<strlen(buf); ++i) {
1016 if (buf[i] == '#') buf[i] = 0;
1019 if (strlen(buf) > 0) {
1020 fprintf(changefp, "%s|%s\n", entrytype, buf);
1026 /* now write it to the server... */
1027 CtdlIPC_putline(ipc, "SNET");
1028 CtdlIPC_getline(ipc, buf);
1029 if (buf[0] == '4') {
1030 changefp = fopen(changefile, "r");
1031 if (changefp != NULL) {
1032 while (fgets(buf, sizeof buf,
1033 changefp) != NULL) {
1034 buf[strlen(buf) - 1] = 0;
1035 CtdlIPC_putline(ipc, buf);
1039 CtdlIPC_putline(ipc, "000");
1043 unlink(filename); /* Delete the temporary files */
1049 * IGnet node configuration
1051 void do_ignet_configuration(CtdlIPC *ipc) {
1061 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1062 CtdlIPC_putline(ipc, buf);
1063 CtdlIPC_getline(ipc, buf);
1064 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1066 if (num_recs == 1) recs = malloc(sizeof(char *));
1067 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1068 recs[num_recs-1] = malloc(SIZ);
1069 strcpy(recs[num_recs-1], buf);
1074 color(BRIGHT_WHITE);
1083 "------------------ "
1084 "-------------------------------- "
1086 for (i=0; i<num_recs; ++i) {
1088 scr_printf("%3d ", i+1);
1089 extract(buf, recs[i], 0);
1091 scr_printf("%-16s ", buf);
1092 extract(buf, recs[i], 1);
1093 color(BRIGHT_MAGENTA);
1094 scr_printf("%-18s ", buf);
1095 extract(buf, recs[i], 2);
1097 scr_printf("%-32s ", buf);
1098 extract(buf, recs[i], 3);
1099 color(BRIGHT_MAGENTA);
1100 scr_printf("%-3s\n", buf);
1104 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1109 recs = malloc(sizeof(char *));
1110 else recs = realloc(recs,
1111 (sizeof(char *)) * num_recs);
1112 newprompt("Enter node name : ", buf, 16);
1114 newprompt("Enter shared secret: ",
1115 &buf[strlen(buf)], 18);
1117 newprompt("Enter host or IP : ",
1118 &buf[strlen(buf)], 32);
1119 strcat(buf, "|504");
1120 strprompt("Enter port number : ",
1121 &buf[strlen(buf)-3], 5);
1122 recs[num_recs-1] = strdup(buf);
1125 i = intprompt("Delete which one",
1126 1, 1, num_recs) - 1;
1129 for (j=i; j<num_recs; ++j)
1130 recs[j] = recs[j+1];
1133 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1134 CtdlIPC_putline(ipc, buf);
1135 CtdlIPC_getline(ipc, buf);
1136 if (buf[0] == '4') {
1137 for (i=0; i<num_recs; ++i) {
1138 CtdlIPC_putline(ipc, recs[i]);
1140 CtdlIPC_putline(ipc, "000");
1143 scr_printf("%s\n", &buf[4]);
1148 quitting = boolprompt(
1149 "Quit without saving", 0);
1154 } while (quitting == 0);
1157 for (i=0; i<num_recs; ++i) free(recs[i]);
1163 * Filter list configuration
1165 void do_filterlist_configuration(CtdlIPC *ipc)
1176 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1177 CtdlIPC_putline(ipc, buf);
1178 CtdlIPC_getline(ipc, buf);
1179 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1181 if (num_recs == 1) recs = malloc(sizeof(char *));
1182 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1183 recs[num_recs-1] = malloc(SIZ);
1184 strcpy(recs[num_recs-1], buf);
1189 color(BRIGHT_WHITE);
1197 "---------------------------- "
1198 "---------------------------- "
1201 for (i=0; i<num_recs; ++i) {
1203 scr_printf("%3d ", i+1);
1204 extract(buf, recs[i], 0);
1206 scr_printf("%-28s ", buf);
1207 extract(buf, recs[i], 1);
1208 color(BRIGHT_MAGENTA);
1209 scr_printf("%-28s ", buf);
1210 extract(buf, recs[i], 2);
1212 scr_printf("%-16s\n", buf);
1213 extract(buf, recs[i], 3);
1217 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1222 recs = malloc(sizeof(char *));
1223 else recs = realloc(recs,
1224 (sizeof(char *)) * num_recs);
1225 newprompt("Enter user name: ", buf, 28);
1227 newprompt("Enter room name: ",
1228 &buf[strlen(buf)], 28);
1230 newprompt("Enter node name: ",
1231 &buf[strlen(buf)], 16);
1233 recs[num_recs-1] = strdup(buf);
1236 i = intprompt("Delete which one",
1237 1, 1, num_recs) - 1;
1240 for (j=i; j<num_recs; ++j)
1241 recs[j] = recs[j+1];
1244 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1245 CtdlIPC_putline(ipc, buf);
1246 CtdlIPC_getline(ipc, buf);
1247 if (buf[0] == '4') {
1248 for (i=0; i<num_recs; ++i) {
1249 CtdlIPC_putline(ipc, recs[i]);
1251 CtdlIPC_putline(ipc, "000");
1254 scr_printf("%s\n", &buf[4]);
1259 quitting = boolprompt(
1260 "Quit without saving", 0);
1265 } while (quitting == 0);
1268 for (i=0; i<num_recs; ++i) free(recs[i]);