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"
47 /* work around solaris include files */
53 extern char tempdir[];
54 extern char *axdefs[7];
55 extern long highest_msg_read;
56 extern long maxmsgnum;
57 extern unsigned room_flags;
58 extern int screenwidth;
62 int eopen(char *name, int mode)
65 ret = open(name, mode);
67 err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
76 int room_prompt(unsigned int qrflags)
77 { /* return proper room prompt character */
80 if (qrflags & QR_DIRECTORY)
82 if ((a == ']') && (qrflags & QR_NETWORK))
84 if ((a == '>') && (qrflags & QR_NETWORK))
89 void entregis(CtdlIPC *ipc)
90 { /* register with name and address */
100 char tmpcountry[SIZ];
106 int r; /* IPC response code */
111 strcpy(tmpstate, "");
113 strcpy(tmpphone, "");
114 strcpy(tmpemail, "");
115 strcpy(tmpcountry, "");
117 r = CtdlIPCGetUserRegistration(ipc, NULL, ®, buf);
121 while (reg && strlen(reg) > 0) {
123 extract_token(buf, reg, 0, '\n');
124 remove_token(reg, 0, '\n');
127 strcpy(tmpname, buf);
129 strcpy(tmpaddr, buf);
131 strcpy(tmpcity, buf);
133 strcpy(tmpstate, buf);
137 strcpy(tmpphone, buf);
139 strcpy(tmpemail, buf);
141 strcpy(tmpcountry, buf);
145 strprompt("REAL name", tmpname, 29);
146 strprompt("Address", tmpaddr, 24);
147 strprompt("City/town", tmpcity, 14);
148 strprompt("State/province", tmpstate, 2);
149 strprompt("ZIP/Postal Code", tmpzip, 10);
150 strprompt("Country", tmpcountry, 31);
151 strprompt("Telephone number", tmpphone, 14);
155 strcpy(holdemail, tmpemail);
156 strprompt("Email address", tmpemail, 31);
157 r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
159 extract_token(diruser, buf, 0, '@');
160 extract_token(dirnode, buf, 1, '@');
163 if ((strcasecmp(diruser, fullname))
164 || (strcasecmp(dirnode, serv_info.serv_nodename))) {
166 "\nYou can't use %s as your address.\n",
169 "It is already in use by %s @ %s.\n",
172 strcpy(tmpemail, holdemail);
177 /* now send the registration info back to the server */
178 reg = (char *)realloc(reg, 4096); /* Overkill? */
180 sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
181 tmpname, tmpaddr, tmpcity, tmpstate,
182 tmpzip, tmpphone, tmpemail, tmpcountry);
183 r = CtdlIPCSetRegistration(ipc, reg, buf);
185 scr_printf("%s\n", buf);
191 void updatels(CtdlIPC *ipc)
192 { /* make all messages old in current room */
194 int r; /* IPC response code */
196 if (rc_alt_semantics) {
197 if (maxmsgnum == 0 && highest_msg_read == 0) {
200 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
201 maxmsgnum : highest_msg_read, buf);
203 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
204 maxmsgnum : highest_msg_read, buf);
205 /* r = CtdlIPCSetLastRead(ipc, maxmsgnum, buf); */
206 /* This is a quick-and-dirty fix to all msgs becoming new in Mail>.
207 * It will need to be rethought when messages.c is rewritten.
211 scr_printf("%s\n", buf);
215 * only make messages old in this room that have been read
217 void updatelsa(CtdlIPC *ipc)
220 int r; /* IPC response code */
222 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
224 scr_printf("%s\n", &buf[4]);
229 * client-based uploads (for users with their own clientware)
231 void cli_upload(CtdlIPC *ipc)
237 int r; /* IPC response code */
241 if ((room_flags & QR_UPLOAD) == 0) {
242 scr_printf("*** You cannot upload to this room.\n");
245 newprompt("File to be uploaded: ", flnm, 55);
246 fd = open(flnm, O_RDONLY);
248 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
251 scr_printf("Enter a description of this file:\n");
252 newprompt(": ", desc, 75);
254 /* Keep generating filenames in hope of finding a unique one */
257 /* basename of filename */
259 if (haschar(tbuf, '/'))
260 strcpy(tbuf, strrchr(tbuf, '/'));
261 /* filename.1, filename.2, etc */
263 sprintf(buf + strlen(buf), ".%d", a);
266 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
267 if (r / 100 == 5 || r < 0)
268 scr_printf("%s\n", buf);
277 * Function used for various image upload commands
279 void cli_image_upload(CtdlIPC *ipc, char *keyname)
285 /* Can we upload this image? */
286 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
288 err_printf("%s\n", buf);
291 newprompt("Image file to be uploaded: ", flnm, 55);
292 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
294 err_printf("%s\n", buf);
296 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
298 /* else upload succeeded */
303 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
305 void upload(CtdlIPC *ipc, int c)
306 { /* c = upload mode */
316 if ((room_flags & QR_UPLOAD) == 0) {
317 scr_printf("*** You cannot upload to this room.\n");
320 /* we don't need a filename when receiving batch y/z modem */
321 if ((c == 2) || (c == 3))
324 newprompt("Enter filename: ", flnm, 15);
326 for (a = 0; a < strlen(flnm); ++a)
327 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
328 || (flnm[a] == '?') || (flnm[a] == '*')
329 || (flnm[a] == ';') || (flnm[a] == '&'))
332 /* create a temporary directory... */
333 if (mkdir(tempdir, 0700) != 0) {
334 scr_printf("*** Could not create temporary directory %s: %s\n",
335 tempdir, strerror(errno));
338 /* now do the transfer ... in a separate process */
345 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
346 fp = fopen(flnm, "w");
362 execlp("rx", "rx", flnm, NULL);
367 execlp("rb", "rb", NULL);
372 execlp("rz", "rz", NULL);
378 } while ((b != xfer_pid) && (b != (-1)));
383 scr_printf("\r*** Transfer unsuccessful.\n");
387 scr_printf("\r*** Transfer successful.\n");
388 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
389 lsfp = popen(buf, "r");
391 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
392 flnm[strlen(flnm) - 1] = 0; /* chop newline */
393 snprintf(buf, sizeof buf,
394 "Enter a short description of '%s':\n: ",
396 newprompt(buf, desc, 150);
397 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
398 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
399 scr_printf("%s\n", tbuf);
407 * validate a user (returns 0 for successful validation, nonzero if quitting)
409 int val_user(CtdlIPC *ipc, char *user, int do_validate)
417 int r; /* IPC response code */
420 r = CtdlIPCGetUserRegistration(ipc, user, &resp, cmd);
424 extract_token(buf, resp, 0, '\n');
425 remove_token(resp, 0, '\n');
428 scr_printf("User #%s - %s ", buf, cmd);
430 scr_printf("PW: %s\n", buf);
432 scr_printf("%s\n", buf);
434 scr_printf("%s\n", buf);
436 scr_printf("%s, ", buf);
438 scr_printf("%s ", buf);
440 scr_printf("%s\n", buf);
442 scr_printf("%s\n", buf);
446 scr_printf("%s\n", buf);
448 scr_printf("%s\n", buf);
449 } while (strlen(resp));
450 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
452 scr_printf("%s\n%s\n", user, &cmd[4]);
454 if (resp) free(resp);
457 /* now set the access level */
459 sprintf(answer, "%d", ax);
460 strprompt("New access level (? for help, q to quit)",
462 if ((answer[0] >= '0') && (answer[0] <= '6')) {
464 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
466 scr_printf("%s\n\n", cmd);
469 if (tolower(answer[0]) == 'q') {
470 scr_printf("*** Aborted.\n\n");
473 if (answer[0] == '?') {
474 scr_printf("Available access levels:\n");
475 for (a=0; a<7; ++a) {
476 scr_printf("%d - %s\n",
486 void validate(CtdlIPC *ipc)
487 { /* validate new users */
491 int r; /* IPC response code */
494 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
498 scr_printf("%s\n", cmd);
500 extract(buf, cmd, 0);
501 if (val_user(ipc, buf, 1) != 0) finished = 1;
503 } while (finished == 0);
513 signal(SIGINT, SIG_DFL);
514 signal(SIGQUIT, SIG_DFL);
515 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
516 err_printf("Could not open a shell: %s\n", strerror(errno));
521 } while ((a != b) && (a != (-1)));
527 * <.A>ide <F>ile <D>elete command
529 void deletefile(CtdlIPC *ipc)
534 newprompt("Filename: ", filename, 31);
535 if (strlen(filename) == 0)
537 CtdlIPCDeleteFile(ipc, filename, buf);
538 err_printf("%s\n", buf);
542 * <.A>ide <F>ile <S>end command
544 void netsendfile(CtdlIPC *ipc)
546 char filename[32], destsys[20], buf[SIZ];
548 newprompt("Filename: ", filename, 31);
549 if (strlen(filename) == 0)
551 newprompt("System to send to: ", destsys, 19);
552 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
553 err_printf("%s\n", buf);
558 * <.A>ide <F>ile <M>ove command
560 void movefile(CtdlIPC *ipc)
563 char newroom[ROOMNAMELEN];
566 newprompt("Filename: ", filename, 63);
567 if (strlen(filename) == 0)
569 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
570 CtdlIPCMoveFile(ipc, filename, newroom, buf);
571 err_printf("%s\n", buf);
576 * list of users who have filled out a bio
578 void list_bio(CtdlIPC *ipc)
583 int r; /* IPC response code */
585 r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
587 pprintf("%s\n", buf);
590 while (strlen(resp)) {
591 extract_token(buf, resp, 0, '\n');
592 remove_token(resp, 0, '\n');
593 if ((pos + strlen(buf) + 5) > screenwidth) {
597 pprintf("%s, ", buf);
598 pos = pos + strlen(buf) + 2;
600 pprintf("%c%c \n\n", 8, 8);
601 if (resp) free(resp);
608 void read_bio(CtdlIPC *ipc)
613 int r; /* IPC response code */
616 newprompt("Read bio for who ('?' for list) : ", who, 25);
618 if (!strcmp(who, "?"))
620 } while (!strcmp(who, "?"));
622 r = CtdlIPCGetBio(ipc, who, &resp, buf);
624 pprintf("%s\n", buf);
627 while (strlen(resp)) {
628 extract_token(buf, resp, 0, '\n');
629 remove_token(resp, 0, '\n');
630 pprintf("%s\n", buf);
632 if (resp) free(resp);
637 * General system configuration command
639 void do_system_configuration(CtdlIPC *ipc)
644 struct ExpirePolicy *expirepolicy = NULL;
647 int r; /* IPC response code */
649 /* Clear out the config buffers */
650 memset(&sc[0][0], 0, sizeof(sc));
652 /* Fetch the current config */
653 r = CtdlIPCGetSystemConfig(ipc, &resp, buf);
656 while (strlen(resp)) {
657 extract_token(buf, resp, 0, '\n');
658 remove_token(resp, 0, '\n');
660 strcpy(&sc[a][0], buf);
665 if (resp) free(resp);
667 /* Fetch the expire policy (this will silently fail on old servers,
668 * resulting in "default" policy)
670 r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf);
672 /* Identification parameters */
674 strprompt("Node name", &sc[0][0], 15);
675 strprompt("Fully qualified domain name", &sc[1][0], 63);
676 strprompt("Human readable node name", &sc[2][0], 20);
677 strprompt("Modem dialup number", &sc[3][0], 15);
678 strprompt("Geographic location of this system", &sc[12][0], 31);
679 strprompt("Name of system administrator", &sc[13][0], 25);
680 strprompt("Paginator prompt", &sc[10][0], 79);
682 /* Security parameters */
684 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
685 "Require registration for new users",
687 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
688 "Disable self-service user account creation",
690 strprompt("Initial access level for new users", &sc[6][0], 1);
691 strprompt("Access level required to create rooms", &sc[19][0], 1);
692 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
693 "Automatically give room aide privs to a user who creates a private room",
696 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
697 "Automatically move problem user messages to twit room",
700 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
701 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
702 "Restrict Internet mail to only those with that privilege",
704 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
705 "Allow Aides to Zap (forget) rooms",
707 snprintf(sc[30], sizeof sc[30], "%d", (boolprompt(
708 "Allow system Aides access to user mailboxes",
711 if (strlen(&sc[18][0]) > 0) logpages = 1;
713 logpages = boolprompt("Log all pages", logpages);
715 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
724 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
725 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
726 strprompt("Maximum message length", &sc[20][0], 20);
727 strprompt("Minimum number of worker threads", &sc[21][0], 3);
728 strprompt("Maximum number of worker threads", &sc[22][0], 3);
730 /* no longer applicable ... deprecated
731 strprompt("Server-to-server networking password", &sc[15][0], 19);
734 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
735 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
736 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
737 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
739 /* This logic flips the question around, because it's one of those
740 * situations where 0=yes and 1=no
744 a = boolprompt("Correct forged From: lines during authenticated SMTP",
747 snprintf(sc[25], sizeof sc[25], "%d", a);
749 /* Expiry settings */
750 strprompt("Default user purge time (days)", &sc[16][0], 5);
751 strprompt("Default room purge time (days)", &sc[17][0], 5);
753 /* Angels and demons dancing in my head... */
755 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
756 strprompt("System default message expire policy (? for list)",
760 "1. Never automatically expire messages\n"
761 "2. Expire by message count\n"
762 "3. Expire by message age\n");
764 } while ((buf[0] < '1') || (buf[0] > '3'));
765 expirepolicy->expire_mode = buf[0] - '0';
767 /* ...lunatics and monsters underneath my bed */
768 if (expirepolicy->expire_mode == 2) {
769 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
770 strprompt("Keep how many messages online?", buf, 10);
771 expirepolicy->expire_value = atol(buf);
773 if (expirepolicy->expire_mode == 3) {
774 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
775 strprompt("Keep messages for how many days?", buf, 10);
776 expirepolicy->expire_value = atol(buf);
778 strprompt("Hour to run purges (0-23)", &sc[31][0], 4);
780 scr_printf("Save this configuration? ");
783 for (a = 0; a < 31; a++)
784 r += 1 + strlen(sc[a]);
785 resp = (char *)calloc(1, r);
787 err_printf("Can't save config - out of memory!\n");
790 for (a = 0; a < 31; a++) {
794 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
796 err_printf("%s\n", buf);
799 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
801 err_printf("%s\n", buf);
808 * support function for do_internet_configuration()
810 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
813 keyopt(" <1> localhost (Alias for this computer)\n");
814 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
815 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
816 keyopt(" <4> directory (Consult the Global Address Book)\n");
817 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
818 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
819 sel = intprompt("Which one", 1, 1, 6);
821 case 1: strcpy(buf, "localhost");
823 case 2: strcpy(buf, "gatewaydomain");
825 case 3: strcpy(buf, "smarthost");
827 case 4: strcpy(buf, "directory");
829 case 5: strcpy(buf, "spamassassin");
831 case 6: strcpy(buf, "rbl");
838 * Internet mail configuration
840 void do_internet_configuration(CtdlIPC *ipc)
852 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
854 while (strlen(resp)) {
855 extract_token(buf, resp, 0, '\n');
856 remove_token(resp, 0, '\n');
858 if (num_recs == 1) recs = malloc(sizeof(char *));
859 else recs = realloc(recs, (sizeof(char *)) * num_recs);
860 recs[num_recs-1] = malloc(strlen(buf) + 1);
861 strcpy(recs[num_recs-1], buf);
864 if (resp) free(resp);
869 scr_printf("### Host or domain Record type \n");
871 scr_printf("--- -------------------------------------------------- --------------------\n");
872 for (i=0; i<num_recs; ++i) {
874 scr_printf("%3d ", i+1);
875 extract(buf, recs[i], 0);
877 scr_printf("%-50s ", buf);
878 extract(buf, recs[i], 1);
879 color(BRIGHT_MAGENTA);
880 scr_printf("%-20s\n", buf);
884 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
887 newprompt("Enter host name: ",
890 if (strlen(buf) > 0) {
893 recs = malloc(sizeof(char *));
894 else recs = realloc(recs,
895 (sizeof(char *)) * num_recs);
897 get_inet_rec_type(ipc,
899 recs[num_recs-1] = strdup(buf);
903 i = intprompt("Delete which one",
907 for (j=i; j<num_recs; ++j)
912 for (i = 0; i < num_recs; i++)
913 r += 1 + strlen(recs[i]);
914 resp = (char *)calloc(1, r);
916 err_printf("Can't save config - out of memory!\n");
919 if (num_recs) for (i = 0; i < num_recs; i++) {
920 strcat(resp, recs[i]);
923 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
925 err_printf("%s\n", buf);
930 quitting = boolprompt(
931 "Quit without saving", 0);
936 } while (quitting == 0);
939 for (i=0; i<num_recs; ++i) free(recs[i]);
947 * Edit network configuration for room sharing, mailing lists, etc.
949 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
951 char filename[PATH_MAX];
952 char changefile[PATH_MAX];
963 if (strlen(editor_paths[0]) == 0) {
964 scr_printf("You must have an external editor configured in"
965 " order to use this function.\n");
969 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
970 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
972 tempfp = fopen(filename, "w");
973 if (tempfp == NULL) {
974 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
978 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
979 fprintf(tempfp, "# %s\n", comment);
980 fprintf(tempfp, "# Specify one per line.\n"
983 CtdlIPC_putline(ipc, "GNET");
984 CtdlIPC_getline(ipc, buf);
986 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
987 extract(instr, buf, 0);
988 if (!strcasecmp(instr, entrytype)) {
989 extract(addr, buf, 1);
990 fprintf(tempfp, "%s\n", addr);
996 e_ex_code = 1; /* start with a failed exit code */
1000 cksum = file_checksum(filename);
1001 if (editor_pid == 0) {
1002 chmod(filename, 0600);
1003 putenv("WINDOW_TITLE=Network configuration");
1004 execlp(editor_paths[0], editor_paths[0], filename, NULL);
1007 if (editor_pid > 0) {
1010 b = ka_wait(&e_ex_code);
1011 } while ((b != editor_pid) && (b >= 0));
1017 if (file_checksum(filename) == cksum) {
1018 err_printf("*** Not saving changes.\n");
1022 if (e_ex_code == 0) { /* Save changes */
1023 changefp = fopen(changefile, "w");
1024 CtdlIPC_putline(ipc, "GNET");
1025 CtdlIPC_getline(ipc, buf);
1026 if (buf[0] == '1') {
1027 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1028 extract(instr, buf, 0);
1029 if (strcasecmp(instr, entrytype)) {
1030 fprintf(changefp, "%s\n", buf);
1034 tempfp = fopen(filename, "r");
1035 while (fgets(buf, sizeof buf, tempfp) != NULL) {
1036 for (i=0; i<strlen(buf); ++i) {
1037 if (buf[i] == '#') buf[i] = 0;
1040 if (strlen(buf) > 0) {
1041 fprintf(changefp, "%s|%s\n", entrytype, buf);
1047 /* now write it to the server... */
1048 CtdlIPC_putline(ipc, "SNET");
1049 CtdlIPC_getline(ipc, buf);
1050 if (buf[0] == '4') {
1051 changefp = fopen(changefile, "r");
1052 if (changefp != NULL) {
1053 while (fgets(buf, sizeof buf,
1054 changefp) != NULL) {
1055 buf[strlen(buf) - 1] = 0;
1056 CtdlIPC_putline(ipc, buf);
1060 CtdlIPC_putline(ipc, "000");
1064 unlink(filename); /* Delete the temporary files */
1070 * IGnet node configuration
1072 void do_ignet_configuration(CtdlIPC *ipc) {
1082 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1083 CtdlIPC_putline(ipc, buf);
1084 CtdlIPC_getline(ipc, buf);
1085 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1087 if (num_recs == 1) recs = malloc(sizeof(char *));
1088 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1089 recs[num_recs-1] = malloc(SIZ);
1090 strcpy(recs[num_recs-1], buf);
1095 color(BRIGHT_WHITE);
1104 "------------------ "
1105 "-------------------------------- "
1107 for (i=0; i<num_recs; ++i) {
1109 scr_printf("%3d ", i+1);
1110 extract(buf, recs[i], 0);
1112 scr_printf("%-16s ", buf);
1113 extract(buf, recs[i], 1);
1114 color(BRIGHT_MAGENTA);
1115 scr_printf("%-18s ", buf);
1116 extract(buf, recs[i], 2);
1118 scr_printf("%-32s ", buf);
1119 extract(buf, recs[i], 3);
1120 color(BRIGHT_MAGENTA);
1121 scr_printf("%-3s\n", buf);
1125 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1130 recs = malloc(sizeof(char *));
1131 else recs = realloc(recs,
1132 (sizeof(char *)) * num_recs);
1133 newprompt("Enter node name : ", buf, 16);
1135 newprompt("Enter shared secret: ",
1136 &buf[strlen(buf)], 18);
1138 newprompt("Enter host or IP : ",
1139 &buf[strlen(buf)], 32);
1140 strcat(buf, "|504");
1141 strprompt("Enter port number : ",
1142 &buf[strlen(buf)-3], 5);
1143 recs[num_recs-1] = strdup(buf);
1146 i = intprompt("Delete which one",
1147 1, 1, num_recs) - 1;
1150 for (j=i; j<num_recs; ++j)
1151 recs[j] = recs[j+1];
1154 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1155 CtdlIPC_putline(ipc, buf);
1156 CtdlIPC_getline(ipc, buf);
1157 if (buf[0] == '4') {
1158 for (i=0; i<num_recs; ++i) {
1159 CtdlIPC_putline(ipc, recs[i]);
1161 CtdlIPC_putline(ipc, "000");
1164 scr_printf("%s\n", &buf[4]);
1169 quitting = boolprompt(
1170 "Quit without saving", 0);
1175 } while (quitting == 0);
1178 for (i=0; i<num_recs; ++i) free(recs[i]);
1184 * Filter list configuration
1186 void do_filterlist_configuration(CtdlIPC *ipc)
1197 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1198 CtdlIPC_putline(ipc, buf);
1199 CtdlIPC_getline(ipc, buf);
1200 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1202 if (num_recs == 1) recs = malloc(sizeof(char *));
1203 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1204 recs[num_recs-1] = malloc(SIZ);
1205 strcpy(recs[num_recs-1], buf);
1210 color(BRIGHT_WHITE);
1218 "---------------------------- "
1219 "---------------------------- "
1222 for (i=0; i<num_recs; ++i) {
1224 scr_printf("%3d ", i+1);
1225 extract(buf, recs[i], 0);
1227 scr_printf("%-28s ", buf);
1228 extract(buf, recs[i], 1);
1229 color(BRIGHT_MAGENTA);
1230 scr_printf("%-28s ", buf);
1231 extract(buf, recs[i], 2);
1233 scr_printf("%-16s\n", buf);
1234 extract(buf, recs[i], 3);
1238 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1243 recs = malloc(sizeof(char *));
1244 else recs = realloc(recs,
1245 (sizeof(char *)) * num_recs);
1246 newprompt("Enter user name: ", buf, 28);
1248 newprompt("Enter room name: ",
1249 &buf[strlen(buf)], 28);
1251 newprompt("Enter node name: ",
1252 &buf[strlen(buf)], 16);
1254 recs[num_recs-1] = strdup(buf);
1257 i = intprompt("Delete which one",
1258 1, 1, num_recs) - 1;
1261 for (j=i; j<num_recs; ++j)
1262 recs[j] = recs[j+1];
1265 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1266 CtdlIPC_putline(ipc, buf);
1267 CtdlIPC_getline(ipc, buf);
1268 if (buf[0] == '4') {
1269 for (i=0; i<num_recs; ++i) {
1270 CtdlIPC_putline(ipc, recs[i]);
1272 CtdlIPC_putline(ipc, "000");
1275 scr_printf("%s\n", &buf[4]);
1280 quitting = boolprompt(
1281 "Quit without saving", 0);
1286 } while (quitting == 0);
1289 for (i=0; i<num_recs; ++i) free(recs[i]);