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"
47 #include "client_crypto.h"
50 extern char tempdir[];
51 extern char *axdefs[7];
52 extern long highest_msg_read;
53 extern long maxmsgnum;
54 extern unsigned room_flags;
55 extern int screenwidth;
59 int eopen(char *name, int mode)
62 ret = open(name, mode);
64 err_printf("Cannot open file '%s', mode=%d, errno=%d\n",
73 int room_prompt(int qrflags)
74 { /* return proper room prompt character */
77 if (qrflags & QR_DIRECTORY)
79 if ((a == ']') && (qrflags & QR_NETWORK))
81 if ((a == '>') && (qrflags & QR_NETWORK))
86 void entregis(CtdlIPC *ipc)
87 { /* register with name and address */
103 int r; /* IPC response code */
108 strcpy(tmpstate, "");
110 strcpy(tmpphone, "");
111 strcpy(tmpemail, "");
112 strcpy(tmpcountry, "");
114 r = CtdlIPCGetUserRegistration(ipc, NULL, ®, buf);
118 while (reg && strlen(reg) > 0) {
120 extract_token(buf, reg, 0, '\n');
121 remove_token(reg, 0, '\n');
124 strcpy(tmpname, buf);
126 strcpy(tmpaddr, buf);
128 strcpy(tmpcity, buf);
130 strcpy(tmpstate, buf);
134 strcpy(tmpphone, buf);
136 strcpy(tmpemail, buf);
138 strcpy(tmpcountry, buf);
142 strprompt("REAL name", tmpname, 29);
143 strprompt("Address", tmpaddr, 24);
144 strprompt("City/town", tmpcity, 14);
145 strprompt("State/province", tmpstate, 2);
146 strprompt("ZIP/Postal Code", tmpzip, 10);
147 strprompt("Country", tmpcountry, 31);
148 strprompt("Telephone number", tmpphone, 14);
152 strcpy(holdemail, tmpemail);
153 strprompt("Email address", tmpemail, 31);
154 r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf);
156 extract_token(diruser, buf, 0, '@');
157 extract_token(dirnode, buf, 1, '@');
160 if ((strcasecmp(diruser, fullname))
161 || (strcasecmp(dirnode, serv_info.serv_nodename))) {
163 "\nYou can't use %s as your address.\n",
166 "It is already in use by %s @ %s.\n",
169 strcpy(tmpemail, holdemail);
174 /* now send the registration info back to the server */
175 reg = (char *)realloc(reg, 4096); /* Overkill? */
177 sprintf(reg, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
178 tmpname, tmpaddr, tmpcity, tmpstate,
179 tmpzip, tmpphone, tmpemail, tmpcountry);
180 r = CtdlIPCSetRegistration(ipc, reg, buf);
182 scr_printf("%s\n", buf);
188 void updatels(CtdlIPC *ipc)
189 { /* make all messages old in current room */
191 int r; /* IPC response code */
193 if (rc_alt_semantics) {
194 if (maxmsgnum == highest_msg_read == 0) {
195 /* err_printf("maxmsgnum == highest_msg_read == 0\n"); */
198 r = CtdlIPCSetLastRead(ipc, (maxmsgnum > highest_msg_read) ?
199 maxmsgnum : highest_msg_read, buf);
201 r = CtdlIPCSetLastRead(ipc, 0, buf);
204 scr_printf("%s\n", buf);
208 * only make messages old in this room that have been read
210 void updatelsa(CtdlIPC *ipc)
213 int r; /* IPC response code */
215 r = CtdlIPCSetLastRead(ipc, highest_msg_read, buf);
217 scr_printf("%s\n", &buf[4]);
222 * This routine completes a client upload
224 void do_upload(CtdlIPC *ipc, int fd)
228 long transmitted_bytes, total_bytes;
232 /* learn the size of the file */
233 total_bytes = lseek(fd, 0L, 2);
236 transmitted_bytes = 0L;
237 progress(transmitted_bytes, total_bytes);
239 bytes_to_send = read(fd, tbuf, 4096);
240 if (bytes_to_send > 0) {
241 snprintf(buf, sizeof buf, "WRIT %d", bytes_to_send);
242 CtdlIPC_putline(ipc, buf);
243 CtdlIPC_getline(ipc, buf);
245 bytes_expected = atoi(&buf[4]);
246 serv_write(ipc, tbuf, bytes_expected);
248 scr_printf("%s\n", &buf[4]);
251 transmitted_bytes = transmitted_bytes + (long) bytes_to_send;
252 progress(transmitted_bytes, total_bytes);
253 } while (bytes_to_send > 0);
255 /* close the upload file, locally and at the server */
257 CtdlIPC_putline(ipc, "UCLS 1");
258 CtdlIPC_getline(ipc, buf);
259 scr_printf("%s\n", &buf[4]);
264 * client-based uploads (for users with their own clientware)
266 void cli_upload(CtdlIPC *ipc)
275 if ((room_flags & QR_UPLOAD) == 0) {
276 scr_printf("*** You cannot upload to this room.\n");
279 newprompt("File to be uploaded: ", flnm, 55);
280 fd = open(flnm, O_RDONLY);
282 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
285 scr_printf("Enter a description of this file:\n");
286 newprompt(": ", desc, 75);
288 /* keep generating filenames in hope of finding a unique one */
292 return; /* fail if tried 10 times */
294 while ((strlen(buf) > 0) && (haschar(buf, '/')))
295 strcpy(buf, &buf[1]);
297 size_t tmp = strlen(buf);
298 snprintf(&buf[tmp], sizeof buf - tmp, "%d", a);
300 snprintf(tbuf, sizeof tbuf, "UOPN %s|%s", buf, desc);
301 CtdlIPC_putline(ipc, tbuf);
302 CtdlIPC_getline(ipc, buf);
304 scr_printf("%s\n", &buf[4]);
306 } while (buf[0] != '2');
308 /* at this point we have an open upload file at the server */
314 * Function used for various image upload commands
316 void cli_image_upload(CtdlIPC *ipc, char *keyname)
322 snprintf(buf, sizeof buf, "UIMG 0|%s", keyname);
323 CtdlIPC_putline(ipc, buf);
324 CtdlIPC_getline(ipc, buf);
326 scr_printf("%s\n", &buf[4]);
329 newprompt("Image file to be uploaded: ", flnm, 55);
330 fd = open(flnm, O_RDONLY);
332 scr_printf("Cannot open '%s': %s\n", flnm, strerror(errno));
335 snprintf(buf, sizeof buf, "UIMG 1|%s", keyname);
336 CtdlIPC_putline(ipc, buf);
337 CtdlIPC_getline(ipc, buf);
339 scr_printf("%s\n", &buf[4]);
347 * protocol-based uploads (Xmodem, Ymodem, Zmodem)
349 void upload(CtdlIPC *ipc, int c)
350 { /* c = upload mode */
360 if ((room_flags & QR_UPLOAD) == 0) {
361 scr_printf("*** You cannot upload to this room.\n");
364 /* we don't need a filename when receiving batch y/z modem */
365 if ((c == 2) || (c == 3))
368 newprompt("Enter filename: ", flnm, 15);
370 for (a = 0; a < strlen(flnm); ++a)
371 if ((flnm[a] == '/') || (flnm[a] == '\\') || (flnm[a] == '>')
372 || (flnm[a] == '?') || (flnm[a] == '*')
373 || (flnm[a] == ';') || (flnm[a] == '&'))
376 newprompt("Enter a short description of the file:\n: ", desc, 150);
378 /* create a temporary directory... */
379 if (mkdir(tempdir, 0700) != 0) {
380 scr_printf("*** Could not create temporary directory %s: %s\n",
381 tempdir, strerror(errno));
384 /* now do the transfer ... in a separate process */
391 scr_printf("Receiving %s - press Ctrl-D to end.\n", flnm);
392 fp = fopen(flnm, "w");
408 execlp("rx", "rx", flnm, NULL);
413 execlp("rb", "rb", NULL);
418 execlp("rz", "rz", NULL);
424 } while ((b != xfer_pid) && (b != (-1)));
429 scr_printf("\r*** Transfer unsuccessful.\n");
433 scr_printf("\r*** Transfer successful. Sending file(s) to server...\n");
434 snprintf(buf, sizeof buf, "cd %s; ls", tempdir);
435 lsfp = popen(buf, "r");
437 while (fgets(flnm, sizeof flnm, lsfp) != NULL) {
438 flnm[strlen(flnm) - 1] = 0;
439 snprintf(buf, sizeof buf, "%s/%s", tempdir, flnm);
440 fd = open(buf, O_RDONLY);
444 snprintf(buf, sizeof buf, "UOPN %s|%s", flnm, desc);
446 size_t tmp = strlen(buf);
452 CtdlIPC_putline(ipc, buf);
453 CtdlIPC_getline(ipc, buf);
454 } while ((buf[0] != '2') && (a < 100));
457 a = read(fd, tbuf, 4096);
459 snprintf(buf, sizeof buf, "WRIT %d", a);
460 CtdlIPC_putline(ipc, buf);
461 CtdlIPC_getline(ipc, buf);
463 serv_write(ipc, tbuf, a);
467 CtdlIPC_putline(ipc, "UCLS 1");
468 CtdlIPC_getline(ipc, buf);
469 scr_printf("%s\n", &buf[4]);
480 void val_user(CtdlIPC *ipc, char *user, int do_validate)
486 int r; /* IPC response code */
488 snprintf(cmd, sizeof cmd, "GREG %s", user);
489 CtdlIPC_putline(ipc, cmd);
490 CtdlIPC_getline(ipc, cmd);
494 CtdlIPC_getline(ipc, buf);
497 scr_printf("User #%s - %s ", buf, &cmd[4]);
499 scr_printf("PW: %s\n", buf);
501 scr_printf("%s\n", buf);
503 scr_printf("%s\n", buf);
505 scr_printf("%s, ", buf);
507 scr_printf("%s ", buf);
509 scr_printf("%s\n", buf);
511 scr_printf("%s\n", buf);
515 scr_printf("%s\n", buf);
517 scr_printf("%s\n", buf);
518 } while (strcmp(buf, "000"));
519 scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]);
521 scr_printf("%-30s\n%s\n", user, &cmd[4]);
525 /* now set the access level */
526 ax = intprompt("Access level", ax, 0, 6);
527 r = CtdlIPCValidateUser(ipc, user, ax, cmd);
529 scr_printf("%s\n", cmd);
535 void validate(CtdlIPC *ipc)
536 { /* validate new users */
540 int r; /* IPC response code */
543 r = CtdlIPCNextUnvalidatedUser(ipc, cmd);
547 scr_printf("%s\n", cmd);
549 extract(buf, cmd, 0);
550 val_user(ipc, buf, 1);
552 } while (finished == 0);
562 signal(SIGINT, SIG_DFL);
563 signal(SIGQUIT, SIG_DFL);
564 execlp(getenv("SHELL"), getenv("SHELL"), NULL);
565 err_printf("Could not open a shell: %s\n", strerror(errno));
570 } while ((a != b) && (a != (-1)));
576 * <.A>ide <F>ile <D>elete command
578 void deletefile(CtdlIPC *ipc)
583 newprompt("Filename: ", filename, 31);
584 if (strlen(filename) == 0)
586 CtdlIPCDeleteFile(ipc, filename, buf);
587 err_printf("%s\n", buf);
591 * <.A>ide <F>ile <S>end command
593 void netsendfile(CtdlIPC *ipc)
595 char filename[32], destsys[20], buf[SIZ];
597 newprompt("Filename: ", filename, 31);
598 if (strlen(filename) == 0)
600 newprompt("System to send to: ", destsys, 19);
601 CtdlIPCNetSendFile(ipc, filename, destsys, buf);
602 err_printf("%s\n", buf);
607 * <.A>ide <F>ile <M>ove command
609 void movefile(CtdlIPC *ipc)
612 char newroom[ROOMNAMELEN];
615 newprompt("Filename: ", filename, 63);
616 if (strlen(filename) == 0)
618 newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1);
619 CtdlIPCMoveFile(ipc, filename, newroom, buf);
620 err_printf("%s\n", buf);
625 * list of users who have filled out a bio
627 void list_bio(CtdlIPC *ipc)
632 CtdlIPC_putline(ipc, "LBIO");
633 CtdlIPC_getline(ipc, buf);
635 pprintf("%s\n", &buf[4]);
638 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
639 if ((pos + strlen(buf) + 5) > screenwidth) {
643 pprintf("%s, ", buf);
644 pos = pos + strlen(buf) + 2;
646 pprintf("%c%c \n\n", 8, 8);
653 void read_bio(CtdlIPC *ipc)
659 newprompt("Read bio for who ('?' for list) : ", who, 25);
661 if (!strcmp(who, "?"))
663 } while (!strcmp(who, "?"));
664 snprintf(buf, sizeof buf, "RBIO %s", who);
665 CtdlIPC_putline(ipc, buf);
666 CtdlIPC_getline(ipc, buf);
668 pprintf("%s\n", &buf[4]);
671 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
672 pprintf("%s\n", buf);
678 * General system configuration command
680 void do_system_configuration(CtdlIPC *ipc)
685 int expire_value = 0;
689 /* Clear out the config buffers */
690 memset(&sc[0][0], 0, sizeof(sc));
692 /* Fetch the current config */
693 CtdlIPC_putline(ipc, "CONF get");
694 CtdlIPC_getline(ipc, buf);
697 while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
699 strcpy(&sc[a][0], buf);
704 /* Fetch the expire policy (this will silently fail on old servers,
705 * resulting in "default" policy)
707 CtdlIPC_putline(ipc, "GPEX site");
708 CtdlIPC_getline(ipc, buf);
710 expire_mode = extract_int(&buf[4], 0);
711 expire_value = extract_int(&buf[4], 1);
715 /* Identification parameters */
717 strprompt("Node name", &sc[0][0], 15);
718 strprompt("Fully qualified domain name", &sc[1][0], 63);
719 strprompt("Human readable node name", &sc[2][0], 20);
720 strprompt("Modem dialup number", &sc[3][0], 15);
721 strprompt("Geographic location of this system", &sc[12][0], 31);
722 strprompt("Name of system administrator", &sc[13][0], 25);
723 strprompt("Paginator prompt", &sc[10][0], 79);
725 /* Security parameters */
727 snprintf(sc[7], sizeof sc[7], "%d", (boolprompt(
728 "Require registration for new users",
730 snprintf(sc[29], sizeof sc[29], "%d", (boolprompt(
731 "Disable self-service user account creation",
733 strprompt("Initial access level for new users", &sc[6][0], 1);
734 strprompt("Access level required to create rooms", &sc[19][0], 1);
735 snprintf(sc[4], sizeof sc[4], "%d", (boolprompt(
736 "Automatically give room aide privs to a user who creates a private room",
739 snprintf(sc[8], sizeof sc[8], "%d", (boolprompt(
740 "Automatically move problem user messages to twit room",
743 strprompt("Name of twit room", &sc[9][0], ROOMNAMELEN);
744 snprintf(sc[11], sizeof sc[11], "%d", (boolprompt(
745 "Restrict Internet mail to only those with that privilege",
747 snprintf(sc[26], sizeof sc[26], "%d", (boolprompt(
748 "Allow Aides to Zap (forget) rooms",
750 snprintf(sc[30], sizeof sc[29], "%d", (boolprompt(
751 "Allow system Aides access to user mailboxes",
754 if (strlen(&sc[18][0]) > 0) logpages = 1;
756 logpages = boolprompt("Log all pages", logpages);
758 strprompt("Name of logging room", &sc[18][0], ROOMNAMELEN);
767 strprompt("Server connection idle timeout (in seconds)", &sc[5][0], 4);
768 strprompt("Maximum concurrent sessions", &sc[14][0], 4);
769 strprompt("Maximum message length", &sc[20][0], 20);
770 strprompt("Minimum number of worker threads", &sc[21][0], 3);
771 strprompt("Maximum number of worker threads", &sc[22][0], 3);
773 /* no longer applicable ... deprecated
774 strprompt("Server-to-server networking password", &sc[15][0], 19);
777 strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5);
778 strprompt("SMTP server port (-1 to disable)", &sc[24][0], 5);
779 strprompt("POP3 server port (-1 to disable)", &sc[23][0], 5);
780 strprompt("IMAP server port (-1 to disable)", &sc[27][0], 5);
782 /* Expiry settings */
783 strprompt("Default user purge time (days)", &sc[16][0], 5);
784 strprompt("Default room purge time (days)", &sc[17][0], 5);
786 /* Angels and demons dancing in my head... */
788 snprintf(buf, sizeof buf, "%d", expire_mode);
789 strprompt("System default message expire policy (? for list)",
793 "1. Never automatically expire messages\n"
794 "2. Expire by message count\n"
795 "3. Expire by message age\n");
797 } while ((buf[0] < 49) || (buf[0] > 51));
798 expire_mode = buf[0] - 48;
800 /* ...lunatics and monsters underneath my bed */
801 if (expire_mode == 2) {
802 snprintf(buf, sizeof buf, "%d", expire_value);
803 strprompt("Keep how many messages online?", buf, 10);
804 expire_value = atol(buf);
806 if (expire_mode == 3) {
807 snprintf(buf, sizeof buf, "%d", expire_value);
808 strprompt("Keep messages for how many days?", buf, 10);
809 expire_value = atol(buf);
812 scr_printf("Save this configuration? ");
814 CtdlIPC_putline(ipc, "CONF set");
815 CtdlIPC_getline(ipc, buf);
817 for (a = 0; a < 31; ++a)
818 CtdlIPC_putline(ipc, &sc[a][0]);
819 CtdlIPC_putline(ipc, "000");
821 snprintf(buf, sizeof buf, "SPEX site|%d|%d",
822 expire_mode, expire_value);
823 CtdlIPC_putline(ipc, buf);
824 CtdlIPC_getline(ipc, buf);
830 * support function for do_internet_configuration()
832 void get_inet_rec_type(CtdlIPC *ipc, char *buf) {
835 keyopt(" <1> localhost (Alias for this computer)\n");
836 keyopt(" <2> gateway domain (Domain for all Citadel systems)\n");
837 keyopt(" <3> smart-host (Forward all outbound mail to this host)\n");
838 keyopt(" <4> directory (Consult the Global Address Book)\n");
839 keyopt(" <5> SpamAssassin (Address of SpamAssassin server)\n");
840 sel = intprompt("Which one", 1, 1, 5);
842 case 1: strcpy(buf, "localhost");
844 case 2: strcpy(buf, "gatewaydomain");
846 case 3: strcpy(buf, "smarthost");
848 case 4: strcpy(buf, "directory");
850 case 5: strcpy(buf, "spamassassin");
857 * Internet mail configuration
859 void do_internet_configuration(CtdlIPC *ipc)
870 snprintf(buf, sizeof buf, "CONF getsys|%s", INTERNETCFG);
871 CtdlIPC_putline(ipc, buf);
872 CtdlIPC_getline(ipc, buf);
873 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
875 if (num_recs == 1) recs = malloc(sizeof(char *));
876 else recs = realloc(recs, (sizeof(char *)) * num_recs);
877 recs[num_recs-1] = malloc(SIZ);
878 strcpy(recs[num_recs-1], buf);
884 scr_printf("### Host or domain Record type \n");
886 scr_printf("--- -------------------------------------------------- --------------------\n");
887 for (i=0; i<num_recs; ++i) {
889 scr_printf("%3d ", i+1);
890 extract(buf, recs[i], 0);
892 scr_printf("%-50s ", buf);
893 extract(buf, recs[i], 1);
894 color(BRIGHT_MAGENTA);
895 scr_printf("%-20s\n", buf);
899 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
904 recs = malloc(sizeof(char *));
905 else recs = realloc(recs,
906 (sizeof(char *)) * num_recs);
907 newprompt("Enter host name: ",
910 get_inet_rec_type(ipc, &buf[strlen(buf)]);
911 recs[num_recs-1] = strdup(buf);
914 i = intprompt("Delete which one",
918 for (j=i; j<num_recs; ++j)
922 snprintf(buf, sizeof buf, "CONF putsys|%s",
924 CtdlIPC_putline(ipc, buf);
925 CtdlIPC_getline(ipc, buf);
927 for (i=0; i<num_recs; ++i) {
928 CtdlIPC_putline(ipc, recs[i]);
930 CtdlIPC_putline(ipc, "000");
933 scr_printf("%s\n", &buf[4]);
938 quitting = boolprompt(
939 "Quit without saving", 0);
944 } while (quitting == 0);
947 for (i=0; i<num_recs; ++i) free(recs[i]);
955 * Edit network configuration for room sharing, mailing lists, etc.
957 void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
959 char filename[PATH_MAX];
960 char changefile[PATH_MAX];
971 if (strlen(editor_path) == 0) {
972 scr_printf("You must have an external editor configured in"
973 " order to use this function.\n");
977 snprintf(filename, sizeof filename, "%s.listedit", tmpnam(NULL));
978 snprintf(changefile, sizeof changefile, "%s.listedit", tmpnam(NULL));
980 tempfp = fopen(filename, "w");
981 if (tempfp == NULL) {
982 err_printf("Cannot open %s: %s\n", filename, strerror(errno));
986 fprintf(tempfp, "# Configuration for room: %s\n", room_name);
987 fprintf(tempfp, "# %s\n", comment);
988 fprintf(tempfp, "# Specify one per line.\n"
991 CtdlIPC_putline(ipc, "GNET");
992 CtdlIPC_getline(ipc, buf);
994 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
995 extract(instr, buf, 0);
996 if (!strcasecmp(instr, entrytype)) {
997 extract(addr, buf, 1);
998 fprintf(tempfp, "%s\n", addr);
1004 e_ex_code = 1; /* start with a failed exit code */
1005 editor_pid = fork();
1006 cksum = file_checksum(filename);
1007 if (editor_pid == 0) {
1008 chmod(filename, 0600);
1010 sttybbs(SB_RESTORE);
1011 putenv("WINDOW_TITLE=Network configuration");
1012 execlp(editor_path, editor_path, filename, NULL);
1015 if (editor_pid > 0) {
1018 b = ka_wait(&e_ex_code);
1019 } while ((b != editor_pid) && (b >= 0));
1025 if (file_checksum(filename) == cksum) {
1026 err_printf("*** Not saving changes.\n");
1030 if (e_ex_code == 0) { /* Save changes */
1031 changefp = fopen(changefile, "w");
1032 CtdlIPC_putline(ipc, "GNET");
1033 CtdlIPC_getline(ipc, buf);
1034 if (buf[0] == '1') {
1035 while(CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1036 extract(instr, buf, 0);
1037 if (strcasecmp(instr, entrytype)) {
1038 fprintf(changefp, "%s\n", buf);
1042 tempfp = fopen(filename, "r");
1043 while (fgets(buf, sizeof buf, tempfp) != NULL) {
1044 for (i=0; i<strlen(buf); ++i) {
1045 if (buf[i] == '#') buf[i] = 0;
1048 if (strlen(buf) > 0) {
1049 fprintf(changefp, "%s|%s\n", entrytype, buf);
1055 /* now write it to the server... */
1056 CtdlIPC_putline(ipc, "SNET");
1057 CtdlIPC_getline(ipc, buf);
1058 if (buf[0] == '4') {
1059 changefp = fopen(changefile, "r");
1060 if (changefp != NULL) {
1061 while (fgets(buf, sizeof buf,
1062 changefp) != NULL) {
1063 buf[strlen(buf) - 1] = 0;
1064 CtdlIPC_putline(ipc, buf);
1068 CtdlIPC_putline(ipc, "000");
1072 unlink(filename); /* Delete the temporary files */
1078 * IGnet node configuration
1080 void do_ignet_configuration(CtdlIPC *ipc) {
1090 snprintf(buf, sizeof buf, "CONF getsys|%s", IGNETCFG);
1091 CtdlIPC_putline(ipc, buf);
1092 CtdlIPC_getline(ipc, buf);
1093 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1095 if (num_recs == 1) recs = malloc(sizeof(char *));
1096 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1097 recs[num_recs-1] = malloc(SIZ);
1098 strcpy(recs[num_recs-1], buf);
1103 color(BRIGHT_WHITE);
1112 "------------------ "
1113 "-------------------------------- "
1115 for (i=0; i<num_recs; ++i) {
1117 scr_printf("%3d ", i+1);
1118 extract(buf, recs[i], 0);
1120 scr_printf("%-16s ", buf);
1121 extract(buf, recs[i], 1);
1122 color(BRIGHT_MAGENTA);
1123 scr_printf("%-18s ", buf);
1124 extract(buf, recs[i], 2);
1126 scr_printf("%-32s ", buf);
1127 extract(buf, recs[i], 3);
1128 color(BRIGHT_MAGENTA);
1129 scr_printf("%-3s\n", buf);
1133 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1138 recs = malloc(sizeof(char *));
1139 else recs = realloc(recs,
1140 (sizeof(char *)) * num_recs);
1141 newprompt("Enter node name : ", buf, 16);
1143 newprompt("Enter shared secret: ",
1144 &buf[strlen(buf)], 18);
1146 newprompt("Enter host or IP : ",
1147 &buf[strlen(buf)], 32);
1148 strcat(buf, "|504");
1149 strprompt("Enter port number : ",
1150 &buf[strlen(buf)-3], 5);
1151 recs[num_recs-1] = strdup(buf);
1154 i = intprompt("Delete which one",
1155 1, 1, num_recs) - 1;
1158 for (j=i; j<num_recs; ++j)
1159 recs[j] = recs[j+1];
1162 snprintf(buf, sizeof buf, "CONF putsys|%s", IGNETCFG);
1163 CtdlIPC_putline(ipc, buf);
1164 CtdlIPC_getline(ipc, buf);
1165 if (buf[0] == '4') {
1166 for (i=0; i<num_recs; ++i) {
1167 CtdlIPC_putline(ipc, recs[i]);
1169 CtdlIPC_putline(ipc, "000");
1172 scr_printf("%s\n", &buf[4]);
1177 quitting = boolprompt(
1178 "Quit without saving", 0);
1183 } while (quitting == 0);
1186 for (i=0; i<num_recs; ++i) free(recs[i]);
1192 * Filter list configuration
1194 void do_filterlist_configuration(CtdlIPC *ipc)
1205 snprintf(buf, sizeof buf, "CONF getsys|%s", FILTERLIST);
1206 CtdlIPC_putline(ipc, buf);
1207 CtdlIPC_getline(ipc, buf);
1208 if (buf[0] == '1') while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) {
1210 if (num_recs == 1) recs = malloc(sizeof(char *));
1211 else recs = realloc(recs, (sizeof(char *)) * num_recs);
1212 recs[num_recs-1] = malloc(SIZ);
1213 strcpy(recs[num_recs-1], buf);
1218 color(BRIGHT_WHITE);
1226 "---------------------------- "
1227 "---------------------------- "
1230 for (i=0; i<num_recs; ++i) {
1232 scr_printf("%3d ", i+1);
1233 extract(buf, recs[i], 0);
1235 scr_printf("%-28s ", buf);
1236 extract(buf, recs[i], 1);
1237 color(BRIGHT_MAGENTA);
1238 scr_printf("%-28s ", buf);
1239 extract(buf, recs[i], 2);
1241 scr_printf("%-16s\n", buf);
1242 extract(buf, recs[i], 3);
1246 ch = keymenu("", "<A>dd|<D>elete|<S>ave|<Q>uit");
1251 recs = malloc(sizeof(char *));
1252 else recs = realloc(recs,
1253 (sizeof(char *)) * num_recs);
1254 newprompt("Enter user name: ", buf, 28);
1256 newprompt("Enter room name: ",
1257 &buf[strlen(buf)], 28);
1259 newprompt("Enter node name: ",
1260 &buf[strlen(buf)], 16);
1262 recs[num_recs-1] = strdup(buf);
1265 i = intprompt("Delete which one",
1266 1, 1, num_recs) - 1;
1269 for (j=i; j<num_recs; ++j)
1270 recs[j] = recs[j+1];
1273 snprintf(buf, sizeof buf, "CONF putsys|%s", FILTERLIST);
1274 CtdlIPC_putline(ipc, buf);
1275 CtdlIPC_getline(ipc, buf);
1276 if (buf[0] == '4') {
1277 for (i=0; i<num_recs; ++i) {
1278 CtdlIPC_putline(ipc, recs[i]);
1280 CtdlIPC_putline(ipc, "000");
1283 scr_printf("%s\n", &buf[4]);
1288 quitting = boolprompt(
1289 "Quit without saving", 0);
1294 } while (quitting == 0);
1297 for (i=0; i<num_recs; ++i) free(recs[i]);