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 == highest_msg_read == 0) {
193 /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
196 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
197 maxmsgnum : highest_msg_read, buf);
199 r = CtdlIPCSetLastRead(ipc, 0, buf);
202 scr_printf("%s\n", buf);
206 * only make messages old in this room that have been read
208 void updatelsa(CtdlIPC *ipc)
211 int r; /* IPC response code */
213 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
215 scr_printf("%s\n", &buf[4]);
220 * client-based uploads (for users with their own clientware)
222 void cli_upload(CtdlIPC *ipc)
228 int r; /* IPC response code */
232 if ((room_flags & QR_UPLOAD) == 0) {
233 scr_printf("*** You cannot upload to this room.\n");
236 newprompt("File to be uploaded: ", flnm, 55);
237 fd = open(flnm, O_RDONLY);
239 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
242 scr_printf("Enter a description of this file:\n");
243 newprompt(": ", desc, 75);
245 /* Keep generating filenames in hope of finding a unique one */
248 /* basename of filename */
250 if (haschar(tbuf, '/'))
251 strcpy(tbuf, strrchr(tbuf, '/'));
252 /* filename.1, filename.2, etc */
254 sprintf(buf + strlen(buf), ".%d", a);
257 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
258 if (r / 100 == 5 || r < 0)
259 scr_printf("%s\n", buf);
268 * Function used for various image upload commands
270 void cli_image_upload(CtdlIPC *ipc, char *keyname)
276 /* Can we upload this image? */
277 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
279 err_printf("%s\n", buf);
282 newprompt("Image file to be uploaded: ", flnm, 55);
283 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
285 err_printf("%s\n", buf);
287 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
289 /* else upload succeeded */
294 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
296 void upload(CtdlIPC *ipc, int c)
297 { /* c = upload mode */
307 if ((room_flags & QR_UPLOAD) == 0) {
308 scr_printf("*** You cannot upload to this room.\n");
311 /* we don't need a filename when receiving batch y/z modem */
312 if ((c == 2) || (c == 3))
315 newprompt("Enter filename: ", flnm, 15);
317 for (a = 0; a < strlen(flnm); ++a)
318 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
319 || (flnm[a] == '?') || (flnm[a] == '*')
320 || (flnm[a] == ';') || (flnm[a] == '&'))
323 /* create a temporary directory... */
324 if (mkdir(tempdir, 0700) != 0) {
325 scr_printf("*** Could not create temporary directory %s: %s\n",
326 tempdir, strerror(errno));
329 /* now do the transfer ... in a separate process */
336 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
337 fp = fopen(flnm, "w");
353 execlp("rx", "rx", flnm, NULL);
358 execlp("rb", "rb", NULL);
363 execlp("rz", "rz", NULL);
369 } while ((b != xfer_pid) && (b != (-1)));
374 scr_printf("\r*** Transfer unsuccessful.\n");
378 scr_printf("\r*** Transfer successful.\n");
379 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
380 lsfp = popen(buf, "r");
382 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
383 flnm[strlen(flnm) - 1] = 0; /* chop newline */
384 snprintf(buf, sizeof buf,
385 "Enter a short description of '%s':\n: ",
387 newprompt(buf, desc, 150);
388 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
389 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
390 scr_printf("%s\n", tbuf);
400 void val_user(CtdlIPC *ipc, char *user, int do_validate)
407 int r; /* IPC response code */
409 r = CtdlIPCGetUserRegistration(ipc, user, &resp, cmd);
413 extract_token(buf, resp, 0, '\n');
414 remove_token(resp, 0, '\n');
417 scr_printf("User #%s - %s ", buf, cmd);
419 scr_printf("PW: %s\n", buf);
421 scr_printf("%s\n", buf);
423 scr_printf("%s\n", buf);
425 scr_printf("%s, ", buf);
427 scr_printf("%s ", buf);
429 scr_printf("%s\n", buf);
431 scr_printf("%s\n", buf);
435 scr_printf("%s\n", buf);
437 scr_printf("%s\n", buf);
438 } while (strlen(resp));
439 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
441 scr_printf("%s\n%s\n", user, &cmd[4]);
443 if (resp) free(resp);
446 /* now set the access level */
447 ax = intprompt("Access level", ax, 0, 6);
448 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
450 scr_printf("%s\n", cmd);
456 void validate(CtdlIPC *ipc)
457 { /* validate new users */
461 int r; /* IPC response code */
464 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
468 scr_printf("%s\n", cmd);
470 extract(buf, cmd, 0);
471 val_user(ipc, buf, 1);
473 } while (finished == 0);
483 signal(SIGINT, SIG_DFL);
484 signal(SIGQUIT, SIG_DFL);
485 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
486 err_printf("Could not open a shell: %s\n", strerror(errno));
491 } while ((a != b) && (a != (-1)));
497 * <.A>ide <F>ile <D>elete command
499 void deletefile(CtdlIPC *ipc)
504 newprompt("Filename: ", filename, 31);
505 if (strlen(filename) == 0)
507 CtdlIPCDeleteFile(ipc, filename, buf);
508 err_printf("%s\n", buf);
512 * <.A>ide <F>ile <S>end command
514 void netsendfile(CtdlIPC *ipc)
516 char filename[32], destsys[20], buf[SIZ];
518 newprompt("Filename: ", filename, 31);
519 if (strlen(filename) == 0)
521 newprompt("System to send to: ", destsys, 19);
522 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
523 err_printf("%s\n", buf);
528 * <.A>ide <F>ile <M>ove command
530 void movefile(CtdlIPC *ipc)
533 char newroom[ROOMNAMELEN];
536 newprompt("Filename: ", filename, 63);
537 if (strlen(filename) == 0)
539 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
540 CtdlIPCMoveFile(ipc, filename, newroom, buf);
541 err_printf("%s\n", buf);
546 * list of users who have filled out a bio
548 void list_bio(CtdlIPC *ipc)
553 int r; /* IPC response code */
555 r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
557 pprintf("%s\n", buf);
560 while (strlen(resp)) {
561 extract_token(buf, resp, 0, '\n');
562 remove_token(resp, 0, '\n');
563 if ((pos + strlen(buf) + 5) > screenwidth) {
567 pprintf("%s, ", buf);
568 pos = pos + strlen(buf) + 2;
570 pprintf("%c%c \n\n", 8, 8);
571 if (resp) free(resp);
578 void read_bio(CtdlIPC *ipc)
583 int r; /* IPC response code */
586 newprompt("Read bio for who ('?' for list) : ", who, 25);
588 if (!strcmp(who, "?"))
590 } while (!strcmp(who, "?"));
592 r = CtdlIPCGetBio(ipc, who, &resp, buf);
594 pprintf("%s\n", buf);
597 while (strlen(resp)) {
598 extract_token(buf, resp, 0, '\n');
599 remove_token(resp, 0, '\n');
600 pprintf("%s\n", buf);
602 if (resp) free(resp);
607 * General system configuration command
609 void do_system_configuration(CtdlIPC *ipc)
614 struct ExpirePolicy *expirepolicy = NULL;
617 int r; /* IPC response code */
619 /* Clear out the config buffers */
620 memset(&sc[0][0], 0, sizeof(sc));
622 /* Fetch the current config */
623 r = CtdlIPCGetSystemConfig(ipc, &resp, buf);
626 while (strlen(resp)) {
627 extract_token(buf, resp, 0, '\n');
628 remove_token(resp, 0, '\n');
630 strcpy(&sc[a][0], buf);
635 if (resp) free(resp);
637 /* Fetch the expire policy (this will silently fail on old servers,
638 * resulting in "default" policy)
640 r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf);
642 /* Identification parameters */
644 strprompt("Node name", &sc[0][0], 15);
645 strprompt("Fully qualified domain name", &sc[1][0], 63);
646 strprompt("Human readable node name", &sc[2][0], 20);
647 strprompt("Modem dialup number", &sc[3][0], 15);
648 strprompt("Geographic location of this system", &sc[12][0], 31);
649 strprompt("Name of system administrator", &sc[13][0], 25);
650 strprompt("Paginator prompt", &sc[10][0], 79);
652 /* Security parameters */
654 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
655 "Require registration for new users",
657 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
658 "Disable self-service user account creation",
660 strprompt("Initial access level for new users", &sc[6][0], 1);
661 strprompt("Access level required to create rooms", &sc[19][0], 1);
662 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
663 "Automatically give room aide privs to a user who creates a private room",
666 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
667 "Automatically move problem user messages to twit room",
670 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
671 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
672 "Restrict Internet mail to only those with that privilege",
674 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
675 "Allow Aides to Zap (forget) rooms",
677 snprintf(sc[30], sizeof sc[29], "%d", (boolprompt(
678 "Allow system Aides access to user mailboxes",
681 if (strlen(&sc[18][0]) > 0) logpages = 1;
683 logpages = boolprompt("Log all pages", logpages);
685 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
694 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
695 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
696 strprompt("Maximum message length", &sc[20][0], 20);
697 strprompt("Minimum number of worker threads", &sc[21][0], 3);
698 strprompt("Maximum number of worker threads", &sc[22][0], 3);
700 /* no longer applicable ... deprecated
701 strprompt("Server-to-server networking password", &sc[15][0], 19);
704 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
705 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
706 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
707 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
709 /* Expiry settings */
710 strprompt("Default user purge time (days)", &sc[16][0], 5);
711 strprompt("Default room purge time (days)", &sc[17][0], 5);
713 /* Angels and demons dancing in my head... */
715 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
716 strprompt("System default message expire policy (? for list)",
720 "1. Never automatically expire messages\n"
721 "2. Expire by message count\n"
722 "3. Expire by message age\n");
724 } while ((buf[0] < '1') || (buf[0] > '3'));
725 expirepolicy->expire_mode = buf[0] - '0';
727 /* ...lunatics and monsters underneath my bed */
728 if (expirepolicy->expire_mode == 2) {
729 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
730 strprompt("Keep how many messages online?", buf, 10);
731 expirepolicy->expire_value = atol(buf);
733 if (expirepolicy->expire_mode == 3) {
734 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
735 strprompt("Keep messages for how many days?", buf, 10);
736 expirepolicy->expire_value = atol(buf);
739 scr_printf("Save this configuration? ");
742 for (a = 0; a < 31; a++)
743 r += 1 + strlen(sc[a]);
744 resp = (char *)calloc(1, r);
746 err_printf("Can't save config - out of memory!\n");
749 for (a = 0; a < 31; a++) {
753 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
755 err_printf("%s\n", buf);
758 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
760 err_printf("%s\n", buf);
767 * support function for do_internet_configuration()
769 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
772 keyopt(" <1> localhost (Alias for this computer)\n");
773 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
774 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
775 keyopt(" <4> directory (Consult the Global Address Book)\n");
776 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
777 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
778 sel = intprompt("Which one", 1, 1, 6);
780 case 1: strcpy(buf, "localhost");
782 case 2: strcpy(buf, "gatewaydomain");
784 case 3: strcpy(buf, "smarthost");
786 case 4: strcpy(buf, "directory");
788 case 5: strcpy(buf, "spamassassin");
790 case 6: strcpy(buf, "rbl");
797 * Internet mail configuration
799 void do_internet_configuration(CtdlIPC *ipc)
811 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
813 while (strlen(resp)) {
814 extract_token(buf, resp, 0, '\n');
815 remove_token(resp, 0, '\n');
817 if (num_recs == 1) recs = malloc(sizeof(char *));
818 else recs = realloc(recs, (sizeof(char *)) * num_recs);
819 recs[num_recs-1] = malloc(strlen(buf) + 1);
820 strcpy(recs[num_recs-1], buf);
823 if (resp) free(resp);
828 scr_printf("### Host or domain Record type \n");
830 scr_printf("--- -------------------------------------------------- --------------------\n");
831 for (i=0; i<num_recs; ++i) {
833 scr_printf("%3d ", i+1);
834 extract(buf, recs[i], 0);
836 scr_printf("%-50s ", buf);
837 extract(buf, recs[i], 1);
838 color(BRIGHT_MAGENTA);
839 scr_printf("%-20s\n", buf);
843 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
846 newprompt("Enter host name: ",
849 if (strlen(buf) > 0) {
852 recs = malloc(sizeof(char *));
853 else recs = realloc(recs,
854 (sizeof(char *)) * num_recs);
856 get_inet_rec_type(ipc,
858 recs[num_recs-1] = strdup(buf);
862 i = intprompt("Delete which one",
866 for (j=i; j<num_recs; ++j)
871 for (i = 0; i < num_recs; i++)
872 r += 1 + strlen(recs[i]);
873 resp = (char *)calloc(1, r);
875 err_printf("Can't save config - out of memory!\n");
878 for (i = 0; i < num_recs; i++) {
879 strcat(resp, recs[i]);
882 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
884 err_printf("%s\n", buf);
889 quitting = boolprompt(
890 "Quit without saving", 0);
895 } while (quitting == 0);
898 for (i=0; i<num_recs; ++i) free(recs[i]);
906 * Edit network configuration for room sharing, mailing lists, etc.
908 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
910 char filename[PATH_MAX];
911 char changefile[PATH_MAX];
922 if (strlen(editor_paths[0]) == 0) {
923 scr_printf("You must have an external editor configured in"
924 " order to use this function.\n");
928 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
929 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
931 tempfp = fopen(filename, "w");
932 if (tempfp == NULL) {
933 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
937 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
938 fprintf(tempfp, "# %s\n", comment);
939 fprintf(tempfp, "# Specify one per line.\n"
942 CtdlIPC_putline(ipc, "GNET");
943 CtdlIPC_getline(ipc, buf);
945 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
946 extract(instr, buf, 0);
947 if (!strcasecmp(instr, entrytype)) {
948 extract(addr, buf, 1);
949 fprintf(tempfp, "%s\n", addr);
955 e_ex_code = 1; /* start with a failed exit code */
959 cksum = file_checksum(filename);
960 if (editor_pid == 0) {
961 chmod(filename, 0600);
962 putenv("WINDOW_TITLE=Network configuration");
963 execlp(editor_paths[0], editor_paths[0], filename, NULL);
966 if (editor_pid > 0) {
969 b = ka_wait(&e_ex_code);
970 } while ((b != editor_pid) && (b >= 0));
976 if (file_checksum(filename) == cksum) {
977 err_printf("*** Not saving changes.\n");
981 if (e_ex_code == 0) { /* Save changes */
982 changefp = fopen(changefile, "w");
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 fprintf(changefp, "%s\n", buf);
993 tempfp = fopen(filename, "r");
994 while (fgets(buf, sizeof buf, tempfp) != NULL) {
995 for (i=0; i<strlen(buf); ++i) {
996 if (buf[i] == '#') buf[i] = 0;
999 if (strlen(buf) > 0) {
1000 fprintf(changefp, "%s|%s\n", entrytype, buf);
1006 /* now write it to the server... */
1007 CtdlIPC_putline(ipc, "SNET");
1008 CtdlIPC_getline(ipc, buf);
1009 if (buf[0] == '4') {
1010 changefp = fopen(changefile, "r");
1011 if (changefp != NULL) {
1012 while (fgets(buf, sizeof buf,
1013 changefp) != NULL) {
1014 buf[strlen(buf) - 1] = 0;
1015 CtdlIPC_putline(ipc, buf);
1019 CtdlIPC_putline(ipc, "000");
1023 unlink(filename); /* Delete the temporary files */
1029 * IGnet node configuration
1031 void do_ignet_configuration(CtdlIPC *ipc) {
1041 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1042 CtdlIPC_putline(ipc, buf);
1043 CtdlIPC_getline(ipc, buf);
1044 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1046 if (num_recs == 1) recs = malloc(sizeof(char *));
1047 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1048 recs[num_recs-1] = malloc(SIZ);
1049 strcpy(recs[num_recs-1], buf);
1054 color(BRIGHT_WHITE);
1063 "------------------ "
1064 "-------------------------------- "
1066 for (i=0; i<num_recs; ++i) {
1068 scr_printf("%3d ", i+1);
1069 extract(buf, recs[i], 0);
1071 scr_printf("%-16s ", buf);
1072 extract(buf, recs[i], 1);
1073 color(BRIGHT_MAGENTA);
1074 scr_printf("%-18s ", buf);
1075 extract(buf, recs[i], 2);
1077 scr_printf("%-32s ", buf);
1078 extract(buf, recs[i], 3);
1079 color(BRIGHT_MAGENTA);
1080 scr_printf("%-3s\n", buf);
1084 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1089 recs = malloc(sizeof(char *));
1090 else recs = realloc(recs,
1091 (sizeof(char *)) * num_recs);
1092 newprompt("Enter node name : ", buf, 16);
1094 newprompt("Enter shared secret: ",
1095 &buf[strlen(buf)], 18);
1097 newprompt("Enter host or IP : ",
1098 &buf[strlen(buf)], 32);
1099 strcat(buf, "|504");
1100 strprompt("Enter port number : ",
1101 &buf[strlen(buf)-3], 5);
1102 recs[num_recs-1] = strdup(buf);
1105 i = intprompt("Delete which one",
1106 1, 1, num_recs) - 1;
1109 for (j=i; j<num_recs; ++j)
1110 recs[j] = recs[j+1];
1113 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1114 CtdlIPC_putline(ipc, buf);
1115 CtdlIPC_getline(ipc, buf);
1116 if (buf[0] == '4') {
1117 for (i=0; i<num_recs; ++i) {
1118 CtdlIPC_putline(ipc, recs[i]);
1120 CtdlIPC_putline(ipc, "000");
1123 scr_printf("%s\n", &buf[4]);
1128 quitting = boolprompt(
1129 "Quit without saving", 0);
1134 } while (quitting == 0);
1137 for (i=0; i<num_recs; ++i) free(recs[i]);
1143 * Filter list configuration
1145 void do_filterlist_configuration(CtdlIPC *ipc)
1156 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1157 CtdlIPC_putline(ipc, buf);
1158 CtdlIPC_getline(ipc, buf);
1159 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1161 if (num_recs == 1) recs = malloc(sizeof(char *));
1162 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1163 recs[num_recs-1] = malloc(SIZ);
1164 strcpy(recs[num_recs-1], buf);
1169 color(BRIGHT_WHITE);
1177 "---------------------------- "
1178 "---------------------------- "
1181 for (i=0; i<num_recs; ++i) {
1183 scr_printf("%3d ", i+1);
1184 extract(buf, recs[i], 0);
1186 scr_printf("%-28s ", buf);
1187 extract(buf, recs[i], 1);
1188 color(BRIGHT_MAGENTA);
1189 scr_printf("%-28s ", buf);
1190 extract(buf, recs[i], 2);
1192 scr_printf("%-16s\n", buf);
1193 extract(buf, recs[i], 3);
1197 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1202 recs = malloc(sizeof(char *));
1203 else recs = realloc(recs,
1204 (sizeof(char *)) * num_recs);
1205 newprompt("Enter user name: ", buf, 28);
1207 newprompt("Enter room name: ",
1208 &buf[strlen(buf)], 28);
1210 newprompt("Enter node name: ",
1211 &buf[strlen(buf)], 16);
1213 recs[num_recs-1] = strdup(buf);
1216 i = intprompt("Delete which one",
1217 1, 1, num_recs) - 1;
1220 for (j=i; j<num_recs; ++j)
1221 recs[j] = recs[j+1];
1224 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1225 CtdlIPC_putline(ipc, buf);
1226 CtdlIPC_getline(ipc, buf);
1227 if (buf[0] == '4') {
1228 for (i=0; i<num_recs; ++i) {
1229 CtdlIPC_putline(ipc, recs[i]);
1231 CtdlIPC_putline(ipc, "000");
1234 scr_printf("%s\n", &buf[4]);
1239 quitting = boolprompt(
1240 "Quit without saving", 0);
1245 } while (quitting == 0);
1248 for (i=0; i<num_recs; ++i) free(recs[i]);