#include #include #include #include #include #include "internal.h" #include "dnsconf.h" #include "dnsconf.m" #include #include static DNSCONF_HELP_FILE help_forward("forward"); PUBLIC FORWARD::FORWARD( const char *_domain, const char **_ip_addr, int nb_ip) { domain.setfrom (_domain); for (int i=0; iget(); if (s[0] != '\0') fprintf (fout,"\t\t%s;\n",s); } fputs ("\t};\n",fout); fputs ("};\n",fout); } } /* Edit the minimal spec so this dns will act as a secondary for another Return -1 if the user escaped away. Return 0 if the changes are accepted Return 1 if the user wish to delete this entry */ PUBLIC int FORWARD::edit (DNS &dns) { DIALOG dia; dia.newf_str (MSG_R(F_DOMAIN),domain); dia.newf_title (MSG_U(F_FORLIST,"Forwarders server(s)"),1,"",MSG_R(F_FORLIST)); for (int i=0; i<3; i++) addrs.add (new IP_ADDR); dia.newf_str (MSG_R(F_IPSERV),*addrs.getitem(0)); for (int i=1; idomain.cmp(name)==0){ ret = s; break; } } return ret; } PUBLIC void FORWARDS::write (bool bind8, FILE_CFG *fout) const { if (bind8) { for (int i=0; iwrite(bind8,fout); } } PUBLIC void FORWARDS::edit(DNS &dns) { int choice=0; DIALOG_LISTE dia; dia.newf_head ("",MSG_U(H_FORWARDS,"domain\tforwarders\t")); dia.addwhat (MSG_U(I_ADDFOR,"Select [Add] to add one forward spec")); while (1){ int nb = getnb(); for (int i=0; iaddrs.getnb(); a++){ if (!s->addrs.getitem(a)->is_empty()){ pt += sprintf (pt,ctl,s->addrs.getitem(a)->get()); ctl = ",%s"; } } *pt++ = '\t'; *pt = '\0'; dia.set_menuitem (i,s->domain.get(),buf); } dia.remove_last (nb+1); MENU_STATUS code = dia.editmenu (MSG_U(T_FORWARDS,"Forward zones") ,MSG_U(I_FORWARDS ,"You are allowed to edit/add/remove forward zones\n") ,help_forward ,choice,0); if (code == MENU_QUIT || code == MENU_ESCAPE){ break; }else if (code == MENU_ADD){ FORWARD *forw = new FORWARD; if (forw->edit(dns)==0){ add (forw); dns.write(); }else{ delete forw; } }else{ FORWARD *forw = getitem(choice); if (forw != NULL){ int ok = forw->edit(dns); if (ok != -1){ if (ok == 1) remove_del (forw); dns.write(); } } } } }