2 * conf.c -- main driver module for fetchmailconf
4 * For license terms, see the file COPYING in this directory.
12 #if defined(STDC_HEADERS)
15 #if defined(HAVE_UNISTD_H)
22 #include "fetchmail.h"
25 * Note: this function dumps the entire configuration,
26 * after merging of the defaults record (if any). It
27 * is intended to produce output parseable by a configuration
28 * front end, not anything especially comfortable for humans.
31 void dump_config(struct runctl *runp, struct query *querylist)
32 /* dump the in-core configuration in recompilable form */
38 /* now write the edited configuration back to the file */
40 fprintf(stdout, "# fetchmail rc file generated at %s", ctime(&now));
42 if (runp->poll_interval)
43 fprintf(stdout, "set daemon %d\n", runp->poll_interval);
45 fprintf(stdout, "set syslog\n");
47 fprintf(stdout, "set logfile %s\n", runp->logfile);
49 fprintf(stdout, "set idfile %s\n", runp->idfile);
51 fprintf(stdout, "set invisible\n");
53 for (ctl = querylist; ctl; ctl = ctl->next)
56 * First, the server stuff.
58 if (!ctl->server.lead_server)
61 (ctl->server.protocol == P_POP3 &&
62 ctl->server.port == KPOP_PORT &&
63 ctl->server.preauthenticate == A_KERBEROS_V4);
65 if (strcmp(ctl->server.pollname, "defaults") == 0)
66 fputs("defaults ", stdout);
68 fprintf(stdout, "%s %s ",
69 ctl->server.skip ? "skip" : "poll",
70 visbuf(ctl->server.pollname));
72 fprintf(stdout, "via %s ", ctl->server.via);
73 if (ctl->server.protocol != P_AUTO)
74 fprintf(stdout, "with protocol %s ",
75 using_kpop ? "KPOP" : showproto(ctl->server.protocol));
77 fprintf(stdout, "port %d ", ctl->server.port);
78 if (ctl->server.timeout)
79 fprintf(stdout, "timeout %d ", ctl->server.timeout);
80 if (ctl->server.interval)
81 fprintf(stdout, "interval %d ", ctl->server.interval);
82 if (ctl->server.envelope == STRING_DISABLED)
83 fprintf(stdout, "no envelope ");
84 else if (ctl->server.envelope)
85 fprintf(stdout, "envelope \"%s\" ", visbuf(ctl->server.envelope));
86 if (ctl->server.qvirtual)
87 fprintf(stdout, "qvirtual \"%s\" ", visbuf(ctl->server.qvirtual));
88 if (ctl->server.preauthenticate == A_KERBEROS_V4)
89 fprintf(stdout, "auth kerberos_v4 ");
90 #define DUMPOPT(flag, str) \
92 fprintf(stdout, "%s ", str); \
94 fprintf(stdout, "no %s ", str);
95 #if defined(HAVE_GETHOSTBYNAME) && defined(HAVE_RES_SEARCH)
96 if (ctl->server.dns || ctl->server.uidl)
99 #endif /* HAVE_GETHOSTBYNAME && HAVE_RES_SEARCH */
100 fputs("and options ", stdout);
101 #if defined(HAVE_GETHOSTBYNAME) && defined(HAVE_RES_SEARCH)
102 DUMPOPT(ctl->server.dns, "dns");
103 #endif /* HAVE_GETHOSTBYNAME && HAVE_RES_SEARCH */
104 DUMPOPT(ctl->server.uidl, "uidl");
107 /* AKA and loca-domain declarations */
108 if (ctl->server.akalist || ctl->server.localdomains)
111 if (ctl->server.akalist)
115 fprintf(stdout, "aka");
116 for (idp = ctl->server.akalist; idp; idp = idp->next)
117 fprintf(stdout, " %s", visbuf(idp->id));
120 if (ctl->server.akalist && ctl->server.localdomains)
123 if (ctl->server.localdomains)
127 fprintf(stdout, "localdomains");
128 for (idp = ctl->server.localdomains; idp; idp = idp->next)
129 fprintf(stdout, " %s", visbuf(idp->id));
135 if (ctl->server.monitor || ctl->server.interface)
138 if (ctl->server.monitor)
139 fprintf(stdout, "monitor \"%s\" ", ctl->server.monitor);
140 if (ctl->server.interface)
141 fprintf(stdout, "interface \"%s\"", ctl->server.interface);
148 if (ctl->remotename || ctl->password || ctl->localnames)
151 fprintf(stdout, "user \"%s\" ", visbuf(ctl->remotename));
152 if (ctl->remotename && ctl->password)
153 fputs("with ", stdout);
155 fprintf(stdout, "password \"%s\" ", visbuf(ctl->password));
158 fprintf(stdout, "is ");
159 for (idp = ctl->localnames; idp; idp = idp->next)
161 fprintf(stdout, "\"%s\"=\"%s\" ",
162 visbuf(idp->id), visbuf(idp->val.id2));
164 fprintf(stdout, "%s ", visbuf(idp->id));
170 if (ctl->fetchall || ctl->keep || ctl->flush || ctl->rewrite
171 || ctl->stripcr || ctl->forcecr || ctl->pass8bits)
172 fputs("options ", stdout);
173 DUMPOPT(ctl->fetchall, "fetchall");
174 DUMPOPT(ctl->keep, "keep");
175 DUMPOPT(ctl->flush, "flush");
176 DUMPOPT(ctl->rewrite, "rewrite");
177 DUMPOPT(ctl->stripcr, "stripcr");
178 DUMPOPT(ctl->forcecr, "forcecr");
179 DUMPOPT(ctl->pass8bits, "pass8bits");
180 DUMPOPT(ctl->dropstatus, "dropstatus");
181 DUMPOPT(ctl->mimedecode, "mimedecode");
185 fprintf(stdout, "mda \"%s\" ", visbuf(ctl->mda));
188 fprintf(stdout, "netsec \"%s\" ", visbuf(ctl->netsec));
191 fprintf(stdout, "preconnect \"%s\" ", visbuf(ctl->preconnect));
192 if (ctl->postconnect)
193 fprintf(stdout, "postconnect \"%s\" ", visbuf(ctl->postconnect));
195 fprintf(stdout, "fetchlimit %d ", ctl->fetchlimit);
197 fprintf(stdout, "batchlimit %d ", ctl->batchlimit);
203 fprintf(stdout, "smtphost ");
204 for (idp = ctl->smtphunt; idp; idp = idp->next)
205 fprintf(stdout, "%s ", visbuf(idp->id));
208 if (ctl->smtpaddress)
209 fprintf(stdout, "smtpaddress \"%s\" ", visbuf(ctl->smtpaddress));
212 fprintf(stdout, "antispam %d ", ctl->antispam);
214 if (ctl->mailboxes && ctl->mailboxes->id)
218 fprintf(stdout, "mailboxes ");
219 for (idp = ctl->mailboxes; idp; idp = idp->next)
220 fprintf(stdout, "%s ", visbuf(idp->id));
227 /* conf.c ends here */