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);
779 scr_printf("Save this configuration? ");
782 for (a = 0; a < 31; a++)
783 r += 1 + strlen(sc[a]);
784 resp = (char *)calloc(1, r);
786 err_printf("Can't save config - out of memory!\n");
789 for (a = 0; a < 31; a++) {
793 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
795 err_printf("%s\n", buf);
798 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
800 err_printf("%s\n", buf);
807 * support function for do_internet_configuration()
809 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
812 keyopt(" <1> localhost (Alias for this computer)\n");
813 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
814 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
815 keyopt(" <4> directory (Consult the Global Address Book)\n");
816 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
817 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
818 sel = intprompt("Which one", 1, 1, 6);
820 case 1: strcpy(buf, "localhost");
822 case 2: strcpy(buf, "gatewaydomain");
824 case 3: strcpy(buf, "smarthost");
826 case 4: strcpy(buf, "directory");
828 case 5: strcpy(buf, "spamassassin");
830 case 6: strcpy(buf, "rbl");
837 * Internet mail configuration
839 void do_internet_configuration(CtdlIPC *ipc)
851 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
853 while (strlen(resp)) {
854 extract_token(buf, resp, 0, '\n');
855 remove_token(resp, 0, '\n');
857 if (num_recs == 1) recs = malloc(sizeof(char *));
858 else recs = realloc(recs, (sizeof(char *)) * num_recs);
859 recs[num_recs-1] = malloc(strlen(buf) + 1);
860 strcpy(recs[num_recs-1], buf);
863 if (resp) free(resp);
868 scr_printf("### Host or domain Record type \n");
870 scr_printf("--- -------------------------------------------------- --------------------\n");
871 for (i=0; i<num_recs; ++i) {
873 scr_printf("%3d ", i+1);
874 extract(buf, recs[i], 0);
876 scr_printf("%-50s ", buf);
877 extract(buf, recs[i], 1);
878 color(BRIGHT_MAGENTA);
879 scr_printf("%-20s\n", buf);
883 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
886 newprompt("Enter host name: ",
889 if (strlen(buf) > 0) {
892 recs = malloc(sizeof(char *));
893 else recs = realloc(recs,
894 (sizeof(char *)) * num_recs);
896 get_inet_rec_type(ipc,
898 recs[num_recs-1] = strdup(buf);
902 i = intprompt("Delete which one",
906 for (j=i; j<num_recs; ++j)
911 for (i = 0; i < num_recs; i++)
912 r += 1 + strlen(recs[i]);
913 resp = (char *)calloc(1, r);
915 err_printf("Can't save config - out of memory!\n");
918 if (num_recs) for (i = 0; i < num_recs; i++) {
919 strcat(resp, recs[i]);
922 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
924 err_printf("%s\n", buf);
929 quitting = boolprompt(
930 "Quit without saving", 0);
935 } while (quitting == 0);
938 for (i=0; i<num_recs; ++i) free(recs[i]);
946 * Edit network configuration for room sharing, mailing lists, etc.
948 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
950 char filename[PATH_MAX];
951 char changefile[PATH_MAX];
962 if (strlen(editor_paths[0]) == 0) {
963 scr_printf("You must have an external editor configured in"
964 " order to use this function.\n");
968 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
969 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
971 tempfp = fopen(filename, "w");
972 if (tempfp == NULL) {
973 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
977 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
978 fprintf(tempfp, "# %s\n", comment);
979 fprintf(tempfp, "# Specify one per line.\n"
982 CtdlIPC_putline(ipc, "GNET");
983 CtdlIPC_getline(ipc, buf);
985 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
986 extract(instr, buf, 0);
987 if (!strcasecmp(instr, entrytype)) {
988 extract(addr, buf, 1);
989 fprintf(tempfp, "%s\n", addr);
995 e_ex_code = 1; /* start with a failed exit code */
999 cksum = file_checksum(filename);
1000 if (editor_pid == 0) {
1001 chmod(filename, 0600);
1002 putenv("WINDOW_TITLE=Network configuration");
1003 execlp(editor_paths[0], editor_paths[0], filename, NULL);
1006 if (editor_pid > 0) {
1009 b = ka_wait(&e_ex_code);
1010 } while ((b != editor_pid) && (b >= 0));
1016 if (file_checksum(filename) == cksum) {
1017 err_printf("*** Not saving changes.\n");
1021 if (e_ex_code == 0) { /* Save changes */
1022 changefp = fopen(changefile, "w");
1023 CtdlIPC_putline(ipc, "GNET");
1024 CtdlIPC_getline(ipc, buf);
1025 if (buf[0] == '1') {
1026 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1027 extract(instr, buf, 0);
1028 if (strcasecmp(instr, entrytype)) {
1029 fprintf(changefp, "%s\n", buf);
1033 tempfp = fopen(filename, "r");
1034 while (fgets(buf, sizeof buf, tempfp) != NULL) {
1035 for (i=0; i<strlen(buf); ++i) {
1036 if (buf[i] == '#') buf[i] = 0;
1039 if (strlen(buf) > 0) {
1040 fprintf(changefp, "%s|%s\n", entrytype, buf);
1046 /* now write it to the server... */
1047 CtdlIPC_putline(ipc, "SNET");
1048 CtdlIPC_getline(ipc, buf);
1049 if (buf[0] == '4') {
1050 changefp = fopen(changefile, "r");
1051 if (changefp != NULL) {
1052 while (fgets(buf, sizeof buf,
1053 changefp) != NULL) {
1054 buf[strlen(buf) - 1] = 0;
1055 CtdlIPC_putline(ipc, buf);
1059 CtdlIPC_putline(ipc, "000");
1063 unlink(filename); /* Delete the temporary files */
1069 * IGnet node configuration
1071 void do_ignet_configuration(CtdlIPC *ipc) {
1081 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1082 CtdlIPC_putline(ipc, buf);
1083 CtdlIPC_getline(ipc, buf);
1084 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1086 if (num_recs == 1) recs = malloc(sizeof(char *));
1087 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1088 recs[num_recs-1] = malloc(SIZ);
1089 strcpy(recs[num_recs-1], buf);
1094 color(BRIGHT_WHITE);
1103 "------------------ "
1104 "-------------------------------- "
1106 for (i=0; i<num_recs; ++i) {
1108 scr_printf("%3d ", i+1);
1109 extract(buf, recs[i], 0);
1111 scr_printf("%-16s ", buf);
1112 extract(buf, recs[i], 1);
1113 color(BRIGHT_MAGENTA);
1114 scr_printf("%-18s ", buf);
1115 extract(buf, recs[i], 2);
1117 scr_printf("%-32s ", buf);
1118 extract(buf, recs[i], 3);
1119 color(BRIGHT_MAGENTA);
1120 scr_printf("%-3s\n", buf);
1124 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1129 recs = malloc(sizeof(char *));
1130 else recs = realloc(recs,
1131 (sizeof(char *)) * num_recs);
1132 newprompt("Enter node name : ", buf, 16);
1134 newprompt("Enter shared secret: ",
1135 &buf[strlen(buf)], 18);
1137 newprompt("Enter host or IP : ",
1138 &buf[strlen(buf)], 32);
1139 strcat(buf, "|504");
1140 strprompt("Enter port number : ",
1141 &buf[strlen(buf)-3], 5);
1142 recs[num_recs-1] = strdup(buf);
1145 i = intprompt("Delete which one",
1146 1, 1, num_recs) - 1;
1149 for (j=i; j<num_recs; ++j)
1150 recs[j] = recs[j+1];
1153 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1154 CtdlIPC_putline(ipc, buf);
1155 CtdlIPC_getline(ipc, buf);
1156 if (buf[0] == '4') {
1157 for (i=0; i<num_recs; ++i) {
1158 CtdlIPC_putline(ipc, recs[i]);
1160 CtdlIPC_putline(ipc, "000");
1163 scr_printf("%s\n", &buf[4]);
1168 quitting = boolprompt(
1169 "Quit without saving", 0);
1174 } while (quitting == 0);
1177 for (i=0; i<num_recs; ++i) free(recs[i]);
1183 * Filter list configuration
1185 void do_filterlist_configuration(CtdlIPC *ipc)
1196 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1197 CtdlIPC_putline(ipc, buf);
1198 CtdlIPC_getline(ipc, buf);
1199 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1201 if (num_recs == 1) recs = malloc(sizeof(char *));
1202 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1203 recs[num_recs-1] = malloc(SIZ);
1204 strcpy(recs[num_recs-1], buf);
1209 color(BRIGHT_WHITE);
1217 "---------------------------- "
1218 "---------------------------- "
1221 for (i=0; i<num_recs; ++i) {
1223 scr_printf("%3d ", i+1);
1224 extract(buf, recs[i], 0);
1226 scr_printf("%-28s ", buf);
1227 extract(buf, recs[i], 1);
1228 color(BRIGHT_MAGENTA);
1229 scr_printf("%-28s ", buf);
1230 extract(buf, recs[i], 2);
1232 scr_printf("%-16s\n", buf);
1233 extract(buf, recs[i], 3);
1237 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1242 recs = malloc(sizeof(char *));
1243 else recs = realloc(recs,
1244 (sizeof(char *)) * num_recs);
1245 newprompt("Enter user name: ", buf, 28);
1247 newprompt("Enter room name: ",
1248 &buf[strlen(buf)], 28);
1250 newprompt("Enter node name: ",
1251 &buf[strlen(buf)], 16);
1253 recs[num_recs-1] = strdup(buf);
1256 i = intprompt("Delete which one",
1257 1, 1, num_recs) - 1;
1260 for (j=i; j<num_recs; ++j)
1261 recs[j] = recs[j+1];
1264 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1265 CtdlIPC_putline(ipc, buf);
1266 CtdlIPC_getline(ipc, buf);
1267 if (buf[0] == '4') {
1268 for (i=0; i<num_recs; ++i) {
1269 CtdlIPC_putline(ipc, recs[i]);
1271 CtdlIPC_putline(ipc, "000");
1274 scr_printf("%s\n", &buf[4]);
1279 quitting = boolprompt(
1280 "Quit without saving", 0);
1285 } while (quitting == 0);
1288 for (i=0; i<num_recs; ++i) free(recs[i]);