]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/setup/domainname.c
1 /* IPCop setup program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
12 #define _(x) dgettext("setup", x)
21 int handledomainname(void)
23 char domainname
[STRING_SIZE
] = "localdomain";
24 struct keyvalue
*kv
= initkeyvalues();
25 char *values
[] = { domainname
, NULL
}; /* pointers for the values. */
26 struct newtWinEntry entries
[] =
27 { { "", &values
[0], 0,}, { NULL
, NULL
, 0 } };
31 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/main/settings")))
34 errorbox(_("Unable to open settings file"));
38 findkey(kv
, "DOMAINNAME", domainname
);
42 rc
= newtWinEntries(_("Domain name"), _("Enter Domain name"),
43 50, 5, 5, 40, entries
, _("OK"), _("Cancel"), NULL
);
46 strcpy(domainname
, values
[0]);
47 if (!(strlen(domainname
)))
48 errorbox(_("Domain name cannot be empty."));
49 else if (strchr(domainname
, ' '))
50 errorbox(_("Domain name cannot contain spaces."));
51 else if (strlen(domainname
) != strspn(domainname
,
52 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-."))
53 errorbox(_("Domain name may only contain letters, numbers, hyphens and periods."));
56 replacekeyvalue(kv
, "DOMAINNAME", domainname
);
57 writekeyvalues(kv
, CONFIG_ROOT
"/main/settings");