+
+#ifdef ENABLE_NLS
+
+ localechoice = GetLocalePrefs();
+
+#endif
+ /* Defaults */
+ sprintf(http_port, "2000");
+#ifdef HAVE_OPENSSL
+ sprintf(https_port, "443");
+#endif
+ sprintf(hostname, "uds");
+ sprintf(portname, "/usr/local/citadel");
+
+ /* This is a very hackish way of learning the port numbers used
+ * in a previous install, if we are upgrading: read them out of
+ * the existing init script.
+ */
+ if ((stat("/etc/init.d/", &etcinitd) == -1) &&
+ (errno == ENOENT))
+ {
+ if ((stat("/etc/rc.d/init.d/", &etcinitd) == -1) &&
+ (errno == ENOENT))
+ initfile = WEBCITDIR"/webcit.init";
+ else
+ initfile = "/etc/rc.d/init.d/webcit";
+ }
+
+ fp = fopen(initfile, "r");
+ if (fp != NULL) {
+ while (fgets(buf, sizeof buf, fp) != NULL) {
+ if (strlen(buf) > 0) {
+ buf[strlen(buf)-1] = 0; /* strip trailing cr */
+ }
+ if (!strncasecmp(buf, "HTTP_PORT=", 10)) {
+ safestrncpy(http_port, &buf[10], sizeof http_port);
+ }
+#ifdef HAVE_OPENSSL
+ if (!strncasecmp(buf, "HTTPS_PORT=", 11)) {
+ safestrncpy(https_port, &buf[11], sizeof https_port);
+ }
+#endif
+ if (!strncasecmp(buf, "CTDL_HOSTNAME=", 14)) {
+ safestrncpy(hostname, &buf[14], sizeof hostname);
+ }
+ if (!strncasecmp(buf, "CTDL_PORTNAME=", 14)) {
+ safestrncpy(portname, &buf[14], sizeof portname);
+ }
+ }
+ fclose(fp);
+ }
+
+ /* Now ask for the port numbers */