* Stuff for setting up the DHCP server from the setup prog.
*
*/
-
+
+// Translation
+#include <libintl.h>
+#define _(x) dgettext("setup", x)
+
#include "setup.h"
#define TOP 4
extern FILE *flog;
extern char *mylog;
-extern char **ctr;
-
extern int automode;
newtComponent dhcpform;
newtComponent labels[MAX_BOXES];
newtComponent ok, cancel;
char message[1000];
- char *labeltexts[MAX_BOXES] = { ctr[TR_START_ADDRESS], ctr[TR_END_ADDRESS],
- ctr[TR_PRIMARY_DNS], ctr[TR_SECONDARY_DNS], ctr[TR_DEFAULT_LEASE],
- ctr[TR_MAX_LEASE], ctr[TR_DOMAIN_NAME_SUFFIX] };
- char *varnames[MAX_BOXES] = { "START_ADDR_GREEN", "END_ADDR_GREEN",
- "DNS1_GREEN", "DNS2_GREEN",
- "DEFAULT_LEASE_TIME_GREEN", "MAX_LEASE_TIME_GREEN",
- "DOMAIN_NAME_GREEN"};
+ char *labeltexts[MAX_BOXES] = {
+ _("Start address:"),
+ _("End address:"),
+ _("Primary DNS:"),
+ _("Secondary DNS:"),
+ _("Default lease (mins):"),
+ _("Max lease (mins):"),
+ _("Domain name suffix:")
+ };
+ char *varnames[MAX_BOXES] = {
+ "START_ADDR_GREEN",
+ "END_ADDR_GREEN",
+ "DNS1_GREEN",
+ "DNS2_GREEN",
+ "DEFAULT_LEASE_TIME_GREEN",
+ "MAX_LEASE_TIME_GREEN",
+ "DOMAIN_NAME_GREEN"
+ };
char defaults[MAX_BOXES][STRING_SIZE];
int result;
int c;
{
freekeyvalues(dhcpkv);
freekeyvalues(ethernetkv);
- errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
+ errorbox(_("Unable to open settings file"));
return 0;
}
if (!(readkeyvalues(ethernetkv, CONFIG_ROOT "/ethernet/settings")))
{
freekeyvalues(dhcpkv);
freekeyvalues(ethernetkv);
- errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
+ errorbox(_("Unable to open settings file"));
return 0;
}
if (!(readkeyvalues(mainkv, CONFIG_ROOT "/main/settings")))
freekeyvalues(dhcpkv);
freekeyvalues(ethernetkv);
freekeyvalues(mainkv);
- errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
+ errorbox(_("Unable to open settings file"));
return 0;
}
strcpy(defaults[DEFAULT_LEASE_TIME], "60");
strcpy(defaults[MAX_LEASE_TIME], "120");
- sprintf(message, ctr[TR_DHCP_SERVER_CONFIGURATION]);
- newtCenteredWindow(55, 18, message);
+ newtCenteredWindow(55, 18, _("DHCP server configuration"));
dhcpform = newtForm(NULL, NULL, 0);
-
- sprintf(message, ctr[TR_CONFIGURE_DHCP]);
- header = newtTextboxReflowed(1, 1, message, 52, 0, 0, 0);
+
+ header = newtTextboxReflowed(1, 1,
+ _("Configure the DHCP server by entering the settings information."),
+ 52, 0, 0, 0);
newtFormAddComponent(dhcpform, header);
strcpy(temp, ""); findkey(dhcpkv, "ENABLE_GREEN", temp);
startenabled = '*';
else
startenabled = ' ';
- enabledcheckbox = newtCheckbox(2, TOP + 0, ctr[TR_ENABLED], startenabled, " *", &enabledresult);
+ enabledcheckbox = newtCheckbox(2, TOP + 0, _("Enabled"), startenabled, " *", &enabledresult);
newtFormAddComponent(dhcpform, enabledcheckbox);
newtComponentAddCallback(enabledcheckbox, dhcpdialogcallbackdhcp, NULL);
}
- ok = newtButton(10, c + 7, ctr[TR_OK]);
- cancel = newtButton(34, c + 7, ctr[TR_CANCEL]);
+ ok = newtButton(10, c + 7, _("OK"));
+ cancel = newtButton(34, c + 7, _("Cancel"));
newtFormAddComponents(dhcpform, ok, cancel, NULL);
- do
- {
+ do {
error = 0;
newtFormRun(dhcpform, &es);
/* OK was pressed; verify the contents of each entry. */
if (enabledresult == '*')
{
- strcpy(message, ctr[TR_INVALID_FIELDS]);
+ strcpy(message, _("The following fields are invalid:\n\n"));
if (inet_addr(results[START_ADDRESS]) == INADDR_NONE)
{
- strcat(message, ctr[TR_START_ADDRESS_CR]);
+ strcat(message, _("Start address"));
+ strcat(message, "\n");
error = 1;
}
if (inet_addr(results[END_ADDRESS]) == INADDR_NONE)
{
- strcat(message, ctr[TR_END_ADDRESS_CR]);
+ strcat(message, _("End address"));
+ strcat(message, "\n");
error = 1;
}
if (strlen(results[SECONDARY_DNS]))
{
if (inet_addr(results[PRIMARY_DNS]) == INADDR_NONE)
{
- strcat(message, ctr[TR_PRIMARY_DNS_CR]);
+ strcat(message, _("Primary DNS"));
+ strcat(message, "\n");
error = 1;
}
}
{
if (inet_addr(results[SECONDARY_DNS]) == INADDR_NONE)
{
- strcat(message, ctr[TR_SECONDARY_DNS_CR]);
+ strcat(message, _("Secondary DNS"));
+ strcat(message, "\n");
error = 1;
}
}
if (!(atol(results[DEFAULT_LEASE_TIME])))
{
- strcat(message, ctr[TR_DEFAULT_LEASE_CR]);
+ strcat(message, _("Default lease time"));
+ strcat(message, "\n");
error = 1;
}
if (!(atol(results[MAX_LEASE_TIME])))
{
- strcat(message, ctr[TR_MAX_LEASE_CR]);
+ strcat(message, _("Max. lease time"));
+ strcat(message, "\n");
error = 1;
}
}
replacekeyvalue(dhcpkv, "ENABLE_GREEN", "on");
fclose(fopen(CONFIG_ROOT "/dhcp/enable_green", "w"));
chown(CONFIG_ROOT "/dhcp/enable_green", 99, 99);
- mysystem("/usr/local/bin/dhcpctrl enable");
+ mysystem(NULL, "/usr/local/bin/dhcpctrl enable");
}
else
{
replacekeyvalue(dhcpkv, "ENABLE_GREEN", "off");
unlink(CONFIG_ROOT "/dhcp/enable_green");
- mysystem("/usr/local/bin/dhcpctrl disable");
+ mysystem(NULL, "/usr/local/bin/dhcpctrl disable");
}
replacekeyvalue(dhcpkv, "VALID", "yes");
writekeyvalues(dhcpkv, CONFIG_ROOT "/dhcp/settings");
fclose(file);
chown(CONFIG_ROOT "/dhcp/dhcpd.conf", 99, 99);
if (automode == 0)
- mysystem("/usr/local/bin/dhcpctrl enable");
+ mysystem(NULL, "/usr/local/bin/dhcpctrl enable");
}
result = 1;
}
else
result = 0;
- }
- while (error);
+ } while (error);
newtFormDestroy(dhcpform);
newtPopWindow();