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>
36 #include "citadel_ipc.h"
37 #include "citadel_decls.h"
38 #include "routines2.h"
49 extern char tempdir[];
50 extern char *axdefs[7];
51 extern long highest_msg_read;
52 extern long maxmsgnum;
53 extern unsigned room_flags;
54 extern int screenwidth;
58 int eopen(char *name, int mode)
61 ret = open(name, mode);
63 err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
72 int room_prompt(unsigned int qrflags)
73 { /* return proper room prompt character */
76 if (qrflags & QR_DIRECTORY)
78 if ((a == ']') && (qrflags & QR_NETWORK))
80 if ((a == '>') && (qrflags & QR_NETWORK))
85 void entregis(CtdlIPC *ipc)
86 { /* register with name and address */
102 int r; /* IPC response code */
107 strcpy(tmpstate, "");
109 strcpy(tmpphone, "");
110 strcpy(tmpemail, "");
111 strcpy(tmpcountry, "");
113 r = CtdlIPCGetUserRegistration(ipc, NULL, ®, buf);
117 while (reg && strlen(reg) > 0) {
119 extract_token(buf, reg, 0, '\n');
120 remove_token(reg, 0, '\n');
123 strcpy(tmpname, buf);
125 strcpy(tmpaddr, buf);
127 strcpy(tmpcity, buf);
129 strcpy(tmpstate, buf);
133 strcpy(tmpphone, buf);
135 strcpy(tmpemail, buf);
137 strcpy(tmpcountry, buf);
141 strprompt("REAL name", tmpname, 29);
142 strprompt("Address", tmpaddr, 24);
143 strprompt("City/town", tmpcity, 14);
144 strprompt("State/province", tmpstate, 2);
145 strprompt("ZIP/Postal Code", tmpzip, 10);
146 strprompt("Country", tmpcountry, 31);
147 strprompt("Telephone number", tmpphone, 14);
151 strcpy(holdemail, tmpemail);
152 strprompt("Email address", tmpemail, 31);
153 r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
155 extract_token(diruser, buf, 0, '@');
156 extract_token(dirnode, buf, 1, '@');
159 if ((strcasecmp(diruser, fullname))
160 || (strcasecmp(dirnode, serv_info.serv_nodename))) {
162 "\nYou can't use %s as your address.\n",
165 "It is already in use by %s @ %s.\n",
168 strcpy(tmpemail, holdemail);
173 /* now send the registration info back to the server */
174 reg = (char *)realloc(reg, 4096); /* Overkill? */
176 sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
177 tmpname, tmpaddr, tmpcity, tmpstate,
178 tmpzip, tmpphone, tmpemail, tmpcountry);
179 r = CtdlIPCSetRegistration(ipc, reg, buf);
181 scr_printf("%s\n", buf);
187 void updatels(CtdlIPC *ipc)
188 { /* make all messages old in current room */
190 int r; /* IPC response code */
192 if (rc_alt_semantics) {
193 if (maxmsgnum == highest_msg_read == 0) {
194 /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
197 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
198 maxmsgnum : highest_msg_read, buf);
200 r = CtdlIPCSetLastRead(ipc, 0, buf);
203 scr_printf("%s\n", buf);
207 * only make messages old in this room that have been read
209 void updatelsa(CtdlIPC *ipc)
212 int r; /* IPC response code */
214 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
216 scr_printf("%s\n", &buf[4]);
221 * client-based uploads (for users with their own clientware)
223 void cli_upload(CtdlIPC *ipc)
229 int r; /* IPC response code */
233 if ((room_flags & QR_UPLOAD) == 0) {
234 scr_printf("*** You cannot upload to this room.\n");
237 newprompt("File to be uploaded: ", flnm, 55);
238 fd = open(flnm, O_RDONLY);
240 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
243 scr_printf("Enter a description of this file:\n");
244 newprompt(": ", desc, 75);
246 /* Keep generating filenames in hope of finding a unique one */
249 /* basename of filename */
251 if (haschar(tbuf, '/'))
252 strcpy(tbuf, strrchr(tbuf, '/'));
253 /* filename.1, filename.2, etc */
255 sprintf(buf + strlen(buf), ".%d", a);
258 r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
259 if (r / 100 == 5 || r < 0)
260 scr_printf("%s\n", buf);
269 * Function used for various image upload commands
271 void cli_image_upload(CtdlIPC *ipc, char *keyname)
277 /* Can we upload this image? */
278 r = CtdlIPCImageUpload(ipc, 0, NULL, keyname, NULL, buf);
280 err_printf("%s\n", buf);
283 newprompt("Image file to be uploaded: ", flnm, 55);
284 r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf);
286 err_printf("%s\n", buf);
288 err_printf("Cannot upload '%s': %s\n", flnm, strerror(errno));
290 /* else upload succeeded */
295 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
297 void upload(CtdlIPC *ipc, int c)
298 { /* c = upload mode */
308 if ((room_flags & QR_UPLOAD) == 0) {
309 scr_printf("*** You cannot upload to this room.\n");
312 /* we don't need a filename when receiving batch y/z modem */
313 if ((c == 2) || (c == 3))
316 newprompt("Enter filename: ", flnm, 15);
318 for (a = 0; a < strlen(flnm); ++a)
319 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
320 || (flnm[a] == '?') || (flnm[a] == '*')
321 || (flnm[a] == ';') || (flnm[a] == '&'))
324 /* create a temporary directory... */
325 if (mkdir(tempdir, 0700) != 0) {
326 scr_printf("*** Could not create temporary directory %s: %s\n",
327 tempdir, strerror(errno));
330 /* now do the transfer ... in a separate process */
337 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
338 fp = fopen(flnm, "w");
354 execlp("rx", "rx", flnm, NULL);
359 execlp("rb", "rb", NULL);
364 execlp("rz", "rz", NULL);
370 } while ((b != xfer_pid) && (b != (-1)));
375 scr_printf("\r*** Transfer unsuccessful.\n");
379 scr_printf("\r*** Transfer successful.\n");
380 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
381 lsfp = popen(buf, "r");
383 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
384 flnm[strlen(flnm) - 1] = 0; /* chop newline */
385 snprintf(buf, sizeof buf,
386 "Enter a short description of '%s':\n: ",
388 newprompt(buf, desc, 150);
389 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
390 r = CtdlIPCFileUpload(ipc, flnm, desc, buf, progress, tbuf);
391 scr_printf("%s\n", tbuf);
401 void val_user(CtdlIPC *ipc, char *user, int do_validate)
408 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 */
448 ax = intprompt("Access level", ax, 0, 6);
449 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
451 scr_printf("%s\n", cmd);
457 void validate(CtdlIPC *ipc)
458 { /* validate new users */
462 int r; /* IPC response code */
465 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
469 scr_printf("%s\n", cmd);
471 extract(buf, cmd, 0);
472 val_user(ipc, buf, 1);
474 } while (finished == 0);
484 signal(SIGINT, SIG_DFL);
485 signal(SIGQUIT, SIG_DFL);
486 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
487 err_printf("Could not open a shell: %s\n", strerror(errno));
492 } while ((a != b) && (a != (-1)));
498 * <.A>ide <F>ile <D>elete command
500 void deletefile(CtdlIPC *ipc)
505 newprompt("Filename: ", filename, 31);
506 if (strlen(filename) == 0)
508 CtdlIPCDeleteFile(ipc, filename, buf);
509 err_printf("%s\n", buf);
513 * <.A>ide <F>ile <S>end command
515 void netsendfile(CtdlIPC *ipc)
517 char filename[32], destsys[20], buf[SIZ];
519 newprompt("Filename: ", filename, 31);
520 if (strlen(filename) == 0)
522 newprompt("System to send to: ", destsys, 19);
523 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
524 err_printf("%s\n", buf);
529 * <.A>ide <F>ile <M>ove command
531 void movefile(CtdlIPC *ipc)
534 char newroom[ROOMNAMELEN];
537 newprompt("Filename: ", filename, 63);
538 if (strlen(filename) == 0)
540 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
541 CtdlIPCMoveFile(ipc, filename, newroom, buf);
542 err_printf("%s\n", buf);
547 * list of users who have filled out a bio
549 void list_bio(CtdlIPC *ipc)
554 int r; /* IPC response code */
556 r = CtdlIPCListUsersWithBios(ipc, &resp, buf);
558 pprintf("%s\n", buf);
561 while (strlen(resp)) {
562 extract_token(buf, resp, 0, '\n');
563 remove_token(resp, 0, '\n');
564 if ((pos + strlen(buf) + 5) > screenwidth) {
568 pprintf("%s, ", buf);
569 pos = pos + strlen(buf) + 2;
571 pprintf("%c%c \n\n", 8, 8);
572 if (resp) free(resp);
579 void read_bio(CtdlIPC *ipc)
584 int r; /* IPC response code */
587 newprompt("Read bio for who ('?' for list) : ", who, 25);
589 if (!strcmp(who, "?"))
591 } while (!strcmp(who, "?"));
593 r = CtdlIPCGetBio(ipc, who, &resp, buf);
595 pprintf("%s\n", buf);
598 while (strlen(resp)) {
599 extract_token(buf, resp, 0, '\n');
600 remove_token(resp, 0, '\n');
601 pprintf("%s\n", buf);
603 if (resp) free(resp);
608 * General system configuration command
610 void do_system_configuration(CtdlIPC *ipc)
615 struct ExpirePolicy *expirepolicy = NULL;
618 int r; /* IPC response code */
620 /* Clear out the config buffers */
621 memset(&sc[0][0], 0, sizeof(sc));
623 /* Fetch the current config */
624 r = CtdlIPCGetSystemConfig(ipc, &resp, buf);
627 while (strlen(resp)) {
628 extract_token(buf, resp, 0, '\n');
629 remove_token(resp, 0, '\n');
631 strcpy(&sc[a][0], buf);
636 if (resp) free(resp);
638 /* Fetch the expire policy (this will silently fail on old servers,
639 * resulting in "default" policy)
641 r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf);
643 /* Identification parameters */
645 strprompt("Node name", &sc[0][0], 15);
646 strprompt("Fully qualified domain name", &sc[1][0], 63);
647 strprompt("Human readable node name", &sc[2][0], 20);
648 strprompt("Modem dialup number", &sc[3][0], 15);
649 strprompt("Geographic location of this system", &sc[12][0], 31);
650 strprompt("Name of system administrator", &sc[13][0], 25);
651 strprompt("Paginator prompt", &sc[10][0], 79);
653 /* Security parameters */
655 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
656 "Require registration for new users",
658 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
659 "Disable self-service user account creation",
661 strprompt("Initial access level for new users", &sc[6][0], 1);
662 strprompt("Access level required to create rooms", &sc[19][0], 1);
663 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
664 "Automatically give room aide privs to a user who creates a private room",
667 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
668 "Automatically move problem user messages to twit room",
671 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
672 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
673 "Restrict Internet mail to only those with that privilege",
675 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
676 "Allow Aides to Zap (forget) rooms",
678 snprintf(sc[30], sizeof sc[29], "%d", (boolprompt(
679 "Allow system Aides access to user mailboxes",
682 if (strlen(&sc[18][0]) > 0) logpages = 1;
684 logpages = boolprompt("Log all pages", logpages);
686 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
695 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
696 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
697 strprompt("Maximum message length", &sc[20][0], 20);
698 strprompt("Minimum number of worker threads", &sc[21][0], 3);
699 strprompt("Maximum number of worker threads", &sc[22][0], 3);
701 /* no longer applicable ... deprecated
702 strprompt("Server-to-server networking password", &sc[15][0], 19);
705 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
706 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
707 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
708 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
710 /* Expiry settings */
711 strprompt("Default user purge time (days)", &sc[16][0], 5);
712 strprompt("Default room purge time (days)", &sc[17][0], 5);
714 /* Angels and demons dancing in my head... */
716 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode);
717 strprompt("System default message expire policy (? for list)",
721 "1. Never automatically expire messages\n"
722 "2. Expire by message count\n"
723 "3. Expire by message age\n");
725 } while ((buf[0] < '1') || (buf[0] > '3'));
726 expirepolicy->expire_mode = buf[0] - '0';
728 /* ...lunatics and monsters underneath my bed */
729 if (expirepolicy->expire_mode == 2) {
730 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
731 strprompt("Keep how many messages online?", buf, 10);
732 expirepolicy->expire_value = atol(buf);
734 if (expirepolicy->expire_mode == 3) {
735 snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value);
736 strprompt("Keep messages for how many days?", buf, 10);
737 expirepolicy->expire_value = atol(buf);
740 scr_printf("Save this configuration? ");
743 for (a = 0; a < 31; a++)
744 r += 1 + strlen(sc[a]);
745 resp = (char *)calloc(1, r);
747 err_printf("Can't save config - out of memory!\n");
750 for (a = 0; a < 31; a++) {
754 r = CtdlIPCSetSystemConfig(ipc, resp, buf);
756 err_printf("%s\n", buf);
759 r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf);
761 err_printf("%s\n", buf);
768 * support function for do_internet_configuration()
770 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
773 keyopt(" <1> localhost (Alias for this computer)\n");
774 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
775 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
776 keyopt(" <4> directory (Consult the Global Address Book)\n");
777 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
778 keyopt(" <6> RBL (domain suffix of spam hunting RBL)\n");
779 sel = intprompt("Which one", 1, 1, 6);
781 case 1: strcpy(buf, "localhost");
783 case 2: strcpy(buf, "gatewaydomain");
785 case 3: strcpy(buf, "smarthost");
787 case 4: strcpy(buf, "directory");
789 case 5: strcpy(buf, "spamassassin");
791 case 6: strcpy(buf, "rbl");
798 * Internet mail configuration
800 void do_internet_configuration(CtdlIPC *ipc)
812 r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf);
814 while (strlen(resp)) {
815 extract_token(buf, resp, 0, '\n');
816 remove_token(resp, 0, '\n');
818 if (num_recs == 1) recs = malloc(sizeof(char *));
819 else recs = realloc(recs, (sizeof(char *)) * num_recs);
820 recs[num_recs-1] = malloc(strlen(buf) + 1);
821 strcpy(recs[num_recs-1], buf);
824 if (resp) free(resp);
829 scr_printf("### Host or domain Record type \n");
831 scr_printf("--- -------------------------------------------------- --------------------\n");
832 for (i=0; i<num_recs; ++i) {
834 scr_printf("%3d ", i+1);
835 extract(buf, recs[i], 0);
837 scr_printf("%-50s ", buf);
838 extract(buf, recs[i], 1);
839 color(BRIGHT_MAGENTA);
840 scr_printf("%-20s\n", buf);
844 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
847 newprompt("Enter host name: ",
850 if (strlen(buf) > 0) {
853 recs = malloc(sizeof(char *));
854 else recs = realloc(recs,
855 (sizeof(char *)) * num_recs);
857 get_inet_rec_type(ipc,
859 recs[num_recs-1] = strdup(buf);
863 i = intprompt("Delete which one",
867 for (j=i; j<num_recs; ++j)
872 for (i = 0; i < num_recs; i++)
873 r += 1 + strlen(recs[i]);
874 resp = (char *)calloc(1, r);
876 err_printf("Can't save config - out of memory!\n");
879 for (i = 0; i < num_recs; i++) {
880 strcat(resp, recs[i]);
883 r = CtdlIPCSetSystemConfigByType(ipc, INTERNETCFG, resp, buf);
885 err_printf("%s\n", buf);
890 quitting = boolprompt(
891 "Quit without saving", 0);
896 } while (quitting == 0);
899 for (i=0; i<num_recs; ++i) free(recs[i]);
907 * Edit network configuration for room sharing, mailing lists, etc.
909 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
911 char filename[PATH_MAX];
912 char changefile[PATH_MAX];
923 if (strlen(editor_paths[0]) == 0) {
924 scr_printf("You must have an external editor configured in"
925 " order to use this function.\n");
929 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
930 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
932 tempfp = fopen(filename, "w");
933 if (tempfp == NULL) {
934 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
938 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
939 fprintf(tempfp, "# %s\n", comment);
940 fprintf(tempfp, "# Specify one per line.\n"
943 CtdlIPC_putline(ipc, "GNET");
944 CtdlIPC_getline(ipc, buf);
946 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
947 extract(instr, buf, 0);
948 if (!strcasecmp(instr, entrytype)) {
949 extract(addr, buf, 1);
950 fprintf(tempfp, "%s\n", addr);
956 e_ex_code = 1; /* start with a failed exit code */
960 cksum = file_checksum(filename);
961 if (editor_pid == 0) {
962 chmod(filename, 0600);
963 putenv("WINDOW_TITLE=Network configuration");
964 execlp(editor_paths[0], editor_paths[0], filename, NULL);
967 if (editor_pid > 0) {
970 b = ka_wait(&e_ex_code);
971 } while ((b != editor_pid) && (b >= 0));
977 if (file_checksum(filename) == cksum) {
978 err_printf("*** Not saving changes.\n");
982 if (e_ex_code == 0) { /* Save changes */
983 changefp = fopen(changefile, "w");
984 CtdlIPC_putline(ipc, "GNET");
985 CtdlIPC_getline(ipc, buf);
987 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
988 extract(instr, buf, 0);
989 if (strcasecmp(instr, entrytype)) {
990 fprintf(changefp, "%s\n", buf);
994 tempfp = fopen(filename, "r");
995 while (fgets(buf, sizeof buf, tempfp) != NULL) {
996 for (i=0; i<strlen(buf); ++i) {
997 if (buf[i] == '#') buf[i] = 0;
1000 if (strlen(buf) > 0) {
1001 fprintf(changefp, "%s|%s\n", entrytype, buf);
1007 /* now write it to the server... */
1008 CtdlIPC_putline(ipc, "SNET");
1009 CtdlIPC_getline(ipc, buf);
1010 if (buf[0] == '4') {
1011 changefp = fopen(changefile, "r");
1012 if (changefp != NULL) {
1013 while (fgets(buf, sizeof buf,
1014 changefp) != NULL) {
1015 buf[strlen(buf) - 1] = 0;
1016 CtdlIPC_putline(ipc, buf);
1020 CtdlIPC_putline(ipc, "000");
1024 unlink(filename); /* Delete the temporary files */
1030 * IGnet node configuration
1032 void do_ignet_configuration(CtdlIPC *ipc) {
1042 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1043 CtdlIPC_putline(ipc, buf);
1044 CtdlIPC_getline(ipc, buf);
1045 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1047 if (num_recs == 1) recs = malloc(sizeof(char *));
1048 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1049 recs[num_recs-1] = malloc(SIZ);
1050 strcpy(recs[num_recs-1], buf);
1055 color(BRIGHT_WHITE);
1064 "------------------ "
1065 "-------------------------------- "
1067 for (i=0; i<num_recs; ++i) {
1069 scr_printf("%3d ", i+1);
1070 extract(buf, recs[i], 0);
1072 scr_printf("%-16s ", buf);
1073 extract(buf, recs[i], 1);
1074 color(BRIGHT_MAGENTA);
1075 scr_printf("%-18s ", buf);
1076 extract(buf, recs[i], 2);
1078 scr_printf("%-32s ", buf);
1079 extract(buf, recs[i], 3);
1080 color(BRIGHT_MAGENTA);
1081 scr_printf("%-3s\n", buf);
1085 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1090 recs = malloc(sizeof(char *));
1091 else recs = realloc(recs,
1092 (sizeof(char *)) * num_recs);
1093 newprompt("Enter node name : ", buf, 16);
1095 newprompt("Enter shared secret: ",
1096 &buf[strlen(buf)], 18);
1098 newprompt("Enter host or IP : ",
1099 &buf[strlen(buf)], 32);
1100 strcat(buf, "|504");
1101 strprompt("Enter port number : ",
1102 &buf[strlen(buf)-3], 5);
1103 recs[num_recs-1] = strdup(buf);
1106 i = intprompt("Delete which one",
1107 1, 1, num_recs) - 1;
1110 for (j=i; j<num_recs; ++j)
1111 recs[j] = recs[j+1];
1114 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1115 CtdlIPC_putline(ipc, buf);
1116 CtdlIPC_getline(ipc, buf);
1117 if (buf[0] == '4') {
1118 for (i=0; i<num_recs; ++i) {
1119 CtdlIPC_putline(ipc, recs[i]);
1121 CtdlIPC_putline(ipc, "000");
1124 scr_printf("%s\n", &buf[4]);
1129 quitting = boolprompt(
1130 "Quit without saving", 0);
1135 } while (quitting == 0);
1138 for (i=0; i<num_recs; ++i) free(recs[i]);
1144 * Filter list configuration
1146 void do_filterlist_configuration(CtdlIPC *ipc)
1157 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1158 CtdlIPC_putline(ipc, buf);
1159 CtdlIPC_getline(ipc, buf);
1160 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1162 if (num_recs == 1) recs = malloc(sizeof(char *));
1163 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1164 recs[num_recs-1] = malloc(SIZ);
1165 strcpy(recs[num_recs-1], buf);
1170 color(BRIGHT_WHITE);
1178 "---------------------------- "
1179 "---------------------------- "
1182 for (i=0; i<num_recs; ++i) {
1184 scr_printf("%3d ", i+1);
1185 extract(buf, recs[i], 0);
1187 scr_printf("%-28s ", buf);
1188 extract(buf, recs[i], 1);
1189 color(BRIGHT_MAGENTA);
1190 scr_printf("%-28s ", buf);
1191 extract(buf, recs[i], 2);
1193 scr_printf("%-16s\n", buf);
1194 extract(buf, recs[i], 3);
1198 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1203 recs = malloc(sizeof(char *));
1204 else recs = realloc(recs,
1205 (sizeof(char *)) * num_recs);
1206 newprompt("Enter user name: ", buf, 28);
1208 newprompt("Enter room name: ",
1209 &buf[strlen(buf)], 28);
1211 newprompt("Enter node name: ",
1212 &buf[strlen(buf)], 16);
1214 recs[num_recs-1] = strdup(buf);
1217 i = intprompt("Delete which one",
1218 1, 1, num_recs) - 1;
1221 for (j=i; j<num_recs; ++j)
1222 recs[j] = recs[j+1];
1225 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1226 CtdlIPC_putline(ipc, buf);
1227 CtdlIPC_getline(ipc, buf);
1228 if (buf[0] == '4') {
1229 for (i=0; i<num_recs; ++i) {
1230 CtdlIPC_putline(ipc, recs[i]);
1232 CtdlIPC_putline(ipc, "000");
1235 scr_printf("%s\n", &buf[4]);
1240 quitting = boolprompt(
1241 "Quit without saving", 0);
1246 } while (quitting == 0);
1249 for (i=0; i<num_recs; ++i) free(recs[i]);