* inetconf.c: added. Not finished yet.
[citadel.git] / webcit / inetconf.c
1 /* 
2  * inetconf.c
3  *
4  * Functions which handle Internet domain configuration etc.
5  *
6  * $Id$
7  */
8
9 #include <ctype.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <signal.h>
15 #include <sys/types.h>
16 #include <sys/wait.h>
17 #include <sys/socket.h>
18 #include <sys/time.h>
19 #include <limits.h>
20 #include <netinet/in.h>
21 #include <netdb.h>
22 #include <string.h>
23 #include <pwd.h>
24 #include <errno.h>
25 #include <stdarg.h>
26 #include <pthread.h>
27 #include <signal.h>
28 #include "webcit.h"
29
30
31
32 void display_inetconf(void)
33 {
34         char buf[SIZ];
35         char ename[SIZ];
36         char etype[SIZ];
37
38         char *ic_localhost;
39         char *ic_gwdom;
40         char *ic_directory;
41         char *ic_spamass;
42         char *ic_rbl;
43         char *ic_smarthost;
44         char *ic_misc;
45
46         char *which = NULL;
47
48         ic_localhost = strdup("");
49         ic_gwdom = strdup("");
50         ic_directory = strdup("");
51         ic_spamass = strdup("");
52         ic_rbl = strdup("");
53         ic_smarthost = strdup("");
54         ic_misc = strdup("");
55
56         output_headers(3);
57         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
58         wprintf("<SPAN CLASS=\"titlebar\">Internet configuration</SPAN>\n");
59         wprintf("</TD></TR></TABLE>\n");
60
61         serv_printf("CONF GETSYS|application/x-citadel-internet-config");
62         serv_gets(buf);
63         if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
64
65                 extract(ename, buf, 0);
66                 extract(etype, buf, 0);
67                 which = NULL;
68                 if (!strcasecmp(etype, "localhost")) which = ic_localhost;
69                 else if (!strcasecmp(etype, "gatewaydomain")) which = ic_gwdom;
70                 else if (!strcasecmp(etype, "directory")) which = ic_directory;
71                 else if (!strcasecmp(etype, "spamassassin")) which = ic_directory;
72                 else if (!strcasecmp(etype, "rbl")) which = ic_rbl;
73                 else if (!strcasecmp(etype, "smarthost")) which = ic_smarthost;
74
75                 if (which != NULL) {
76                         which = realloc(which, strlen(which) + strlen(ename) + 2);
77                         if (strlen(which) > 0) strcat(which, "\n");
78                         strcat(which, ename);
79                 }
80                 else {
81                         ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
82                         if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
83                         strcat(which, buf);
84                 }
85
86                 /* FIXME finish this */
87                 escputs(buf);
88                 wprintf("<BR>\n");
89         }
90
91         wDumpContent(1);
92
93         free(ic_localhost);
94         free(ic_gwdom);
95         free(ic_directory);
96         free(ic_spamass);
97         free(ic_rbl);
98         free(ic_smarthost);
99         free(ic_misc);
100 }
101
102
103 void save_inetconf(void) {
104
105         strcpy(WC->ImportantMessage, "FIXME did we do anything?");
106
107         display_inetconf();
108 }