#define UI_TEXT 0 /* Default setup type -- text only */
+#define UI_DIALOG 2 /* Use the 'dialog' program */
#define UI_SILENT 3 /* Silent running, for use in scripts */
#define UI_NEWT 4 /* Use the "newt" window library */
strcpy(init_entry, "");
/* Determine the fully qualified path name of webserver */
- snprintf(looking_for, sizeof looking_for, "%s/webserver ", WEBCITDIR);
+ snprintf(looking_for, sizeof looking_for, "%s/webserver ", setup_directory);
/* Pound through /etc/inittab line by line. Set have_entry to 1 if
* an entry is found which we believe starts webserver.
newtComponent form = NULL;
newtComponent yesbutton = NULL;
newtComponent nobutton = NULL;
- int i = 0;
#endif
+ int i = 0;
int answer = 0;
char buf[SIZ];
} while ((answer < 0) || (answer > 1));
break;
+ case UI_DIALOG:
+ sprintf(buf, "exec %s --yesno '%s' 10 72",
+ getenv("CTDL_DIALOG"),
+ question);
+ i = system(buf);
+ if (i == 0) {
+ answer = 1;
+ }
+ else {
+ answer = 0;
+ }
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
newtCenteredWindow(76, 10, "Question");
int i;
#endif
char buf[SIZ];
+ char *dialog_result;
char setupmsg[SIZ];
+ FILE *fp;
strcpy(setupmsg, "");
if (strlen(buf) != 0)
strcpy(str, buf);
break;
+
+ case UI_DIALOG:
+ dialog_result = tmpnam(NULL);
+ sprintf(buf, "exec %s --backtitle '%s' --inputbox '%s' 19 72 '%s' 2>%s",
+ getenv("CTDL_DIALOG"),
+ "WebCit setup",
+ prompt,
+ str,
+ dialog_result);
+ system(buf);
+ fp = fopen(dialog_result, "r");
+ if (fp != NULL) {
+ fgets(str, sizeof buf, fp);
+ if (str[strlen(str)-1] == 10) {
+ str[strlen(str)-1] = 0;
+ }
+ fclose(fp);
+ unlink(dialog_result);
+ }
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
fgets(buf, sizeof buf, stdin);
break;
+ case UI_DIALOG:
+ sprintf(buf, "exec %s --backtitle '%s' --msgbox '%s' 19 72",
+ getenv("CTDL_DIALOG"),
+ title,
+ msgtext);
+ system(buf);
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
newtCenteredWindow(76, 10, title);
#endif
static long dots_printed = 0L;
long a = 0;
+ char buf[SIZ];
+ static FILE *fp = NULL;
switch (setup_type) {
}
break;
+ case UI_DIALOG:
+ if (curr == 0) {
+ sprintf(buf, "exec %s --gauge '%s' 7 72 0",
+ getenv("CTDL_DIALOG"),
+ text);
+ fp = popen(buf, "w");
+ if (fp != NULL) {
+ fprintf(fp, "0\n");
+ fflush(fp);
+ }
+ }
+ else if (curr == cmax) {
+ if (fp != NULL) {
+ fprintf(fp, "100\n");
+ pclose(fp);
+ fp = NULL;
+ }
+ }
+ else {
+ a = (curr * 100) / cmax;
+ if (fp != NULL) {
+ fprintf(fp, "%ld\n", a);
+ fflush(fp);
+ }
+ }
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
if (curr == 0) {
char looking_for[SIZ];
char question[SIZ];
char entryname[5];
- char entryname2[5];
char http_port[128];
+#ifdef HAVE_OPENSSL
char https_port[128];
+#endif
char hostname[128];
char portname[128];
/* Determine the fully qualified path name of webserver */
- snprintf(looking_for, sizeof looking_for, "%s/webserver ", WEBCITDIR);
+ snprintf(looking_for, sizeof looking_for, "%s/webserver", setup_directory);
/* If there's already an entry, then we have nothing left to do. */
if (strlen(init_entry) > 0) {
int discover_ui(void)
{
+ /* Use "dialog" if we have it */
+ if (getenv("CTDL_DIALOG") != NULL) {
+ return UI_DIALOG;
+ }
+
#ifdef HAVE_NEWT
newtInit();
newtCls();