]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame_incremental - src/install+setup/setup/domainname.c
Update translations.
[people/teissler/ipfire-2.x.git] / src / install+setup / setup / domainname.c
... / ...
CommitLineData
1/* IPCop setup program.
2 *
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
5 *
6 * $Id: domainname.c
7 *
8 */
9
10#include "setup.h"
11
12extern FILE *flog;
13extern char *mylog;
14
15extern char **ctr;
16
17extern int automode;
18
19int handledomainname(void)
20{
21 char domainname[STRING_SIZE] = "localdomain";
22 struct keyvalue *kv = initkeyvalues();
23 char *values[] = { domainname, NULL }; /* pointers for the values. */
24 struct newtWinEntry entries[] =
25 { { "", &values[0], 0,}, { NULL, NULL, 0 } };
26 int rc;
27 int result;
28
29 if (!(readkeyvalues(kv, CONFIG_ROOT "/main/settings")))
30 {
31 freekeyvalues(kv);
32 errorbox(ctr[TR_UNABLE_TO_OPEN_SETTINGS_FILE]);
33 return 0;
34 }
35
36 findkey(kv, "DOMAINNAME", domainname);
37
38 for (;;)
39 {
40 rc = newtWinEntries(ctr[TR_DOMAINNAME], ctr[TR_ENTER_DOMAINNAME],
41 50, 5, 5, 40, entries, ctr[TR_OK], ctr[TR_CANCEL], NULL);
42
43 if (rc == 1)
44 {
45 strcpy(domainname, values[0]);
46 if (!(strlen(domainname)))
47 errorbox(ctr[TR_DOMAINNAME_CANNOT_BE_EMPTY]);
48 else if (strchr(domainname, ' '))
49 errorbox(ctr[TR_DOMAINNAME_CANNOT_CONTAIN_SPACES]);
50 else if (strlen(domainname) != strspn(domainname,
51 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-."))
52 errorbox(ctr[TR_DOMAINNAME_NOT_VALID_CHARS]);
53 else
54 {
55 replacekeyvalue(kv, "DOMAINNAME", domainname);
56 writekeyvalues(kv, CONFIG_ROOT "/main/settings");
57 writehostsfiles();
58 result = 1;
59 break;
60 }
61 }
62 else
63 {
64 result = 0;
65 break;
66 }
67 }
68 free(values[0]);
69 freekeyvalues(kv);
70
71 return result;
72}