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.
19 int handledomainname(void)
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 } };
29 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/main/settings")))
32 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
36 findkey(kv
, "DOMAINNAME", domainname
);
40 rc
= newtWinEntries(ctr
[TR_DOMAINNAME
], ctr
[TR_ENTER_DOMAINNAME
],
41 50, 5, 5, 40, entries
, ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
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
]);
55 replacekeyvalue(kv
, "DOMAINNAME", domainname
);
56 writekeyvalues(kv
, CONFIG_ROOT
"/main/settings");