[PC-BSD Commits] r7781 - pcbsd-projects/txt-sysinstall

svn at pcbsd.org svn at pcbsd.org
Tue Oct 12 14:04:39 PDT 2010


Author: johnh
Date: 2010-10-12 14:04:39 -0700 (Tue, 12 Oct 2010)
New Revision: 7781

Modified:
   pcbsd-projects/txt-sysinstall/components.c
   pcbsd-projects/txt-sysinstall/disksel.c
   pcbsd-projects/txt-sysinstall/ftp.c
   pcbsd-projects/txt-sysinstall/install.c
   pcbsd-projects/txt-sysinstall/label.c
   pcbsd-projects/txt-sysinstall/main.c
   pcbsd-projects/txt-sysinstall/mainmenu.c
   pcbsd-projects/txt-sysinstall/medium.c
   pcbsd-projects/txt-sysinstall/netif.c
   pcbsd-projects/txt-sysinstall/packages.c
   pcbsd-projects/txt-sysinstall/partsel.c
   pcbsd-projects/txt-sysinstall/rootpass.c
   pcbsd-projects/txt-sysinstall/txt-sysinstall.h
   pcbsd-projects/txt-sysinstall/tzone.c
   pcbsd-projects/txt-sysinstall/useradd.c
   pcbsd-projects/txt-sysinstall/util.c
Log:
Removed the state handling stuff, approaching it a different way.
Working on better user interaction for adding labels, starting to clean
up some of the bugs. Added config macros that match pc-sysinstall config
directives. 


Modified: pcbsd-projects/txt-sysinstall/components.c
===================================================================
--- pcbsd-projects/txt-sysinstall/components.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/components.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -45,11 +45,11 @@
 static int
 type_fire(dialogMenuItem *self)
 {
-	appendconfig("installType", self->prompt);
+	installType(self->prompt);
 	if (!strcmp(self->prompt, "FreeBSD"))
-		appendconfig("packageType", "split");
+		packageType("split");
 	else
-		appendconfig("packageType", "uzip");
+		packageType("uzip");
 
 	return (0);
 }
@@ -77,7 +77,7 @@
 }
 
 int
-dialog_components(void *args)
+dialog_components(void)
 {
 	char *token;
 	char *buf;
@@ -150,13 +150,12 @@
 		}
 
 		if (notnull(ptr))
-			appendconfig("installComponents", compstr);
+			installComponents(compstr);
 	}
 
 	free(buf);
 	free(compstr);
 	free(menus);
 
-	set_next_dialog("packages", &dialog_packages, NULL, NULL);
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/disksel.c
===================================================================
--- pcbsd-projects/txt-sysinstall/disksel.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/disksel.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -27,6 +27,7 @@
  */
 
 #include <unistd.h>
+#include <search.h>
 #include <string.h>
 #include <stdlib.h>
 #include <dialog.h>
@@ -40,17 +41,47 @@
 disk_fire(dialogMenuItem *self)
 {
 	struct disk_info *di;
-	appendconfig("disk0", self->prompt);
+	char buf[32];
+	int loop;
+	int n;
 
 	di = (struct disk_info *)self->data;
 	di->used = 1;
 
-	set_next_dialog("partsel", &dialog_partsel, di, NULL);
+	n = 0;
+	loop = 1;	
+	while (loop == 1) {
+		ENTRY item, *find;
+
+		bzero(&buf, sizeof(buf));
+		snprintf(buf, sizeof(buf), "disk%d", n);
+
+		item.key = safe_strdup(buf); 
+		item.data = NULL;
+
+		find = hsearch(item, FIND);
+		if (find == NULL) {
+			ENTRY new;
+
+			new.key = safe_strdup(buf);
+			new.data = di;
+			hsearch(new, ENTER);
+
+			loop = 0;
+		}
+
+		free(item.key);
+		n++;
+	}
+
+	appendconfig(buf, self->prompt);
+	set_current_disk(di);
+
 	return (0);
 }
 
 int
-dialog_disksel(void *args)
+dialog_disksel(void)
 {
 	dialogMenuItem *menus;
 	struct disk_list *disks;

Modified: pcbsd-projects/txt-sysinstall/ftp.c
===================================================================
--- pcbsd-projects/txt-sysinstall/ftp.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/ftp.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -67,14 +67,14 @@
 	snprintf(ftpSite, sizeof(ftpSite),
 		"ftp://%s/pub/FreeBSD/releases/%s/%s/",
 		self->title, arch, branch);
-	appendconfig("ftpPath", ftpSite);
+	ftpPath(ftpSite);
 
 	free(buf);
 	return (0);
 }
 
 int
-dialog_ftp(void *args)
+dialog_ftp(void)
 {
 	char *buf;
 	char *token;

Modified: pcbsd-projects/txt-sysinstall/install.c
===================================================================
--- pcbsd-projects/txt-sysinstall/install.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/install.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -187,4 +187,7 @@
 		    "Congratulations, you now have PC-BSD or FreeBSD "
 		    "installed\nin your system.\n\n", 7, 70);
 	}
+
+	system("/bin/sh");
+	exit(0);
 }

Modified: pcbsd-projects/txt-sysinstall/label.c
===================================================================
--- pcbsd-projects/txt-sysinstall/label.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/label.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -96,6 +96,7 @@
 STAILQ_HEAD(zfs_mount_head, zfs_mount) zfs_mount_list = 
 	STAILQ_HEAD_INITIALIZER(zfs_mount_list);
 
+static dialogMenuItem *labels;
 
 static void
 add_label(const char *label, const char *desc, char *password, size_t size, long flags)
@@ -613,10 +614,10 @@
 				strlcat(line, " ", sizeof(line));
 				strlcat(line, li->label, sizeof(line));
 
-				appendconfig("disk0-part", line);
+				disk(0, line);
 
 				if (FS_FLAG_SET(li->flags, FS_FLAGS_ENCRYPT))
-					appendconfig("encpass", li->password);
+					encpass(li->password);
 
 				break;
 			}
@@ -669,10 +670,10 @@
 					free(diskstr);
 				}
 
-				appendconfig("disk0-part", line);
+				disk(0, line);
 
 				if (FS_FLAG_SET(li->flags, FS_FLAGS_ENCRYPT))
-					appendconfig("encpass", li->password);
+					encpass(li->password);
 
 				break;
 			}
@@ -687,16 +688,16 @@
 				strlcat(line, " ", sizeof(line));
 				strlcat(line, li->label, sizeof(line));
 
-				appendconfig("disk0-part", line);
+				disk(0, line);
 
 				if (FS_FLAG_SET(li->flags, FS_FLAGS_ENCRYPT))
-					appendconfig("encpass", li->password);
+					encpass(li->password);
 				break;
 			}
 		}
 	}
 
-	appendconfig("commitDiskLabel", NULL);
+	commitDiskLabel();
 	free_zpool_disk_list();
 }
 
@@ -717,7 +718,7 @@
 
 
 int
-dialog_label(void *args)
+dialog_label(void)
 {
 	int i;
 	char *buf;
@@ -725,6 +726,7 @@
 	int status;
 	dialogMenuItem *menus;
 
+
 	buf = safe_malloc(BUFSZ+1);
 	status = run_pcsysinstall(buf, BUFSZ, "sys-mem", NULL);
 	swap = atoi(buf) * 2 + 2048;
@@ -739,13 +741,12 @@
 		/*
 		 * This is the default label configuration.
 		 */
-		appendconfig("disk0-part", "UFS+S 1024 /");
+		disk(0, "UFS+S 1024 /");
 		snprintf(value, sizeof(value), "SWAP %d none", swap);
-		appendconfig("disk0-part", value);
-		appendconfig("disk0-part", "UFS+S 0 /usr");
-		appendconfig("commitDiskLabel", NULL);
+		disk(0, value);
+		disk(0, "UFS+S 0 /usr");
+		commitDiskLabel();
 
-		set_next_dialog("useradd", &dialog_useradd, NULL, NULL);
 		return (0);
 	}
 
@@ -755,13 +756,14 @@
 	DMENUF(&menus[i++], "Back", NULL, NULL);
 	DMENUF(&menus[i++], "Add Label", "", label_fire);
 
+	DialogX = (COLS - 50) / 2;
+	DialogY = 2;
+
 	screen_clear(MODULE);
 	dialog_menu(MODULE, "BSD partitions:", 12, 50, 3, -i+2,
     	menus+2, "", NULL, NULL);
+	free(menus);
 
-	free(menus);
 	write_disk_labels();
-
-	set_next_dialog("useradd", &dialog_useradd, NULL, NULL);
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/main.c
===================================================================
--- pcbsd-projects/txt-sysinstall/main.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/main.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -27,10 +27,13 @@
  */
 
 #include <dialog.h>
+#include <search.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#define	HASHSZ	1024
+
 #include "txt-sysinstall.h"
 
 static void
@@ -59,9 +62,11 @@
 	setenv("DIALOGRC", style, 1);
 	sysinstall_init();
 	init_dialog();
+	hcreate(HASHSZ);
 
 	sysinstall();
 
+	hdestroy();
 	end_dialog();
 	sysinstall_fini();
 }

Modified: pcbsd-projects/txt-sysinstall/mainmenu.c
===================================================================
--- pcbsd-projects/txt-sysinstall/mainmenu.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/mainmenu.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -38,26 +38,30 @@
 #define MODULE "Main Menu"
 #define	MAXLABELS 8
 
+enum {
+	DO_DISKSEL = 1,
+	DO_NETIF = 2
+};
 
+
 static int
 next_fire(dialogMenuItem *self)
 {
-	set_next_dialog("disksel", &dialog_disksel, NULL, NULL);
+	*((int *)self->data) = DO_DISKSEL;
 	return (0);
 }
 
 static int
 exit_fire(dialogMenuItem *self)
 {
-	//set_next_dialog();
 	return (0);
 }
 
 static int
 install_fire(dialogMenuItem *self)
 {
-	appendconfig("installMode", "fresh");
-	set_next_dialog("disksel", &dialog_disksel, NULL, NULL);
+	installMode("fresh");
+	*((int *)self->data) = DO_DISKSEL;
 
 	return (0);
 }
@@ -65,8 +69,8 @@
 static int
 upgrade_fire(dialogMenuItem *self)
 {
-	appendconfig("installMode", "upgrade");
-	set_next_dialog("disksel", &dialog_disksel, NULL, NULL);
+	installMode("upgrade");
+	*((int *)self->data) = DO_DISKSEL;
 
 	return (0);
 }
@@ -74,7 +78,7 @@
 static int
 netif_fire(dialogMenuItem *self)
 {
-	set_next_dialog("netif", &dialog_netif, NULL, NULL);
+	*((int *)self->data) = DO_NETIF;
 	return (0);
 }
 
@@ -93,20 +97,25 @@
 }
 
 int
-dialog_sysinstall(void *args)
+dialog_sysinstall(void)
 {
 	int i;
 	int res;
+	int dialog;
 	dialogMenuItem *menus;
 
 	i = 0;
+	dialog = 0;
 	menus = safe_malloc(sizeof(*menus)*MAXLABELS+2);
-	DMENUF(&menus[i++], "Next", NULL, next_fire);
+	DMENUFD(&menus[i++], "Next", NULL, next_fire, &dialog);
 	DMENUF(&menus[i++], "Exit", NULL, exit_fire);
-	DMENUF(&menus[i++], "Install", "Install PC-BSD or FreeBSD", install_fire);
-	DMENUF(&menus[i++], "Upgrade", "Upgrade PC-BSD or FreeBSD", upgrade_fire);
-	DMENUF(&menus[i++], "Configure Network", "Setup network interfaces", netif_fire);
-	DMENUF(&menus[i++], "Shell", "Run tcsh", shell_fire);
+	DMENUFD(&menus[i++], "Install", "Install PC-BSD or FreeBSD",
+		install_fire, &dialog);
+	DMENUFD(&menus[i++], "Upgrade", "Upgrade PC-BSD or FreeBSD",
+		upgrade_fire, &dialog);
+	DMENUFD(&menus[i++], "Configure Network", "Setup network interfaces",
+		netif_fire, &dialog);
+	DMENUFD(&menus[i++], "Shell", "Run tcsh", shell_fire, &dialog);
 
 	screen_clear(MODULE);
 	res = dialog_menu("Welcome to "OSNAME" install",
@@ -116,17 +125,33 @@
 	    NULL, NULL);
 
 	free(menus);
+
+	switch(dialog) {
+		case DO_DISKSEL:
+			dialog_disksel();
+			break;
+
+		case DO_NETIF:
+			dialog_netif();
+			break;
+	}
+
 	return (res);
 }
 
 void
 sysinstall(void)
 {
-	struct dialog_state *ds;
+	dialog_sysinstall();
+	dialog_partsel();
+	dialog_label();
+	dialog_useradd();
+	dialog_rootpass();
+	dialog_tzone();
+	dialog_medium();
+	dialog_components();
+	dialog_packages();
 
-	for (;;) {
-		if ((ds = get_next_dialog()) != NULL)
-			if (ds->dialog(ds->args))
-				break;
-	}
+	save_config();
+	do_install();
 }

Modified: pcbsd-projects/txt-sysinstall/medium.c
===================================================================
--- pcbsd-projects/txt-sysinstall/medium.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/medium.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -41,16 +41,16 @@
 medium_fire(dialogMenuItem *self)
 {
 	//char ftpSite[128] = "http://darkstar.ist.utl.pt/pcbsd/current/i386/netinstall/";
-	appendconfig("installMedium", self->data);
+	installMedium(self->data);
 
 	if (!strcmp(self->data, "ftp")) {
-		dialog_ftp(NULL);
+		dialog_ftp();
 /*
 		screen_clear(MODULE);
 		dialog_inputbox("FTP/HTTP mirror", "Please type the "
 		    "URL where to fetch the archives from:",
 		    8, 70, ftpSite);
-		appendconfig("ftpPath", ftpSite);
+		ftpPath(ftpSite);
 */
 	}
 
@@ -59,7 +59,7 @@
 
 
 int
-dialog_medium(void *args)
+dialog_medium(void)
 {
 	dialogMenuItem menus[6];
 	int i;
@@ -82,6 +82,5 @@
 	dialog_menu(MODULE, "Please select the install medium:",
 	    7+i-2, 70, i-2, -i+2, menus+2, "", NULL, NULL);
 
-	set_next_dialog("components", &dialog_components, NULL, NULL);
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/netif.c
===================================================================
--- pcbsd-projects/txt-sysinstall/netif.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/netif.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -81,7 +81,7 @@
 }
 
 int
-dialog_netif(void *args)
+dialog_netif(void)
 {
 	char *token;
 	char *buf;

Modified: pcbsd-projects/txt-sysinstall/packages.c
===================================================================
--- pcbsd-projects/txt-sysinstall/packages.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/packages.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -40,7 +40,6 @@
 
 #define MODULE		"Package selection"
 #define	PKGSTRSIZE	16384	
-#define	HASHSZ		512
 
 struct package_info {
 	char *package;
@@ -334,13 +333,13 @@
 	}
 
 	if (notnull(ptr))
-		appendconfig("installPackages", pkgstr);
+		installPackages(pkgstr);
 
 	free(pkgstr);
 }
 
 int
-dialog_packages(void *args)
+dialog_packages(void)
 {
 	char *buf;
 
@@ -352,16 +351,12 @@
 	run_pcsysinstall(buf, BUFSZ, "list-packages", "@INDEX@");
 	buf[safe_strlen(buf) - 1] = 0;
 
-	hcreate(HASHSZ);
 	parse_package_index(buf);
 	dialog_package_category();
 
 	set_marked_packages();
 	free_package_lists();
-	hdestroy();
 
 	free(buf);
-	save_config();
-	do_install();
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/partsel.c
===================================================================
--- pcbsd-projects/txt-sysinstall/partsel.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/partsel.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -52,15 +52,15 @@
 {
 	switch (self->aux) {
 	case USEALL:
-		appendconfig("partition", "all");
+		partition("all");
 		break;
 
 	case USENEW:
-		appendconfig("partition", "free");
+		partition("free");
 		break;
 
 	default:
-		appendconfig("partition", self->prompt);
+		partition(self->prompt);
 	}
 
 	return (0);
@@ -166,12 +166,44 @@
 	return (md);
 }
 
+void
+dialog_bootloader(void)
+{
+	int bootloader;
+
+	screen_clear("Bootloader");
+	bootloader = dialog_yesno("Bootloader setup",
+	    "Do you want to install a boot loader ?", 5, 60);
+	if (bootloader == FALSE)
+		bootManager("bsd");
+	else
+		bootManager("none");
+}
+
+void
+dialog_mirror(void)
+{
+	screen_clear("MIRROR");
+	if (dialog_noyes("MIRROR", "Configure Mirror?", 5, 10) == 0) {
+		struct mirror_disk *md = configure_gmirror();
+		if (md != NULL) {
+			struct disk_info *gdi;
+
+			mirror(md->disk);
+			mirrorbal(md->balance);
+
+			gdi = get_disk_info_by_disk(md->disk);
+			gdi->used = 1;
+			free(md);
+		}
+	}
+}
+
 int
-dialog_partsel(void *args)
+dialog_partsel(void)
 {
 	int i;
 	int status;
-	int bootloader;
 	char *buf;
 	char *token;
 	char *format;
@@ -184,7 +216,7 @@
 	dialog_busy(5, 60, "Reading partition list...");
 
 	format = NULL;
-	di = (struct disk_info *)args;
+	di = get_current_disk();
 
 	buf = safe_malloc(BUFSZ+1);
 	status = run_pcsysinstall(buf, BUFSZ, "disk-part", di->disk);
@@ -237,31 +269,9 @@
 	free(menus);
 	free(buf);
 
-	screen_clear("Bootloader");
-	bootloader = dialog_noyes("Bootloader setup",
-	    "Do you want to install a boot loader ?", 5, 60);
-	if (bootloader == FALSE)
-		appendconfig("bootManager", "bsd");
-	else
-		appendconfig("bootManager", "none");
+	dialog_bootloader();
+	dialog_mirror();
 
-	screen_clear("MIRROR");
-	if (dialog_noyes("MIRROR", "Configure Mirror?", 5, 10) == 0) {
-		struct mirror_disk *md = configure_gmirror();
-		if (md != NULL) {
-			struct disk_info *gdi;
-
-			appendconfig("mirror", md->disk);
-			appendconfig("mirrorbal", md->balance);
-
-			gdi = get_disk_info_by_disk(md->disk);
-			gdi->used = 1;
-			free(md);
-		}
-	}
-
-	appendconfig("commitDiskPart", NULL);
-
-	set_next_dialog("label", &dialog_label, NULL, NULL);
+	commitDiskPart();
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/rootpass.c
===================================================================
--- pcbsd-projects/txt-sysinstall/rootpass.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/rootpass.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -38,7 +38,7 @@
 
 
 int
-dialog_rootpass(void *args)
+dialog_rootpass(void)
 {
 	int loop;
 	char rootPass1[64];
@@ -66,8 +66,6 @@
 			loop = 0;
 	}
 
-	appendconfig("rootPass", rootPass2);
-
-	set_next_dialog("tzone", &dialog_tzone, NULL, NULL);
+	rootPass(rootPass2);
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/txt-sysinstall.h
===================================================================
--- pcbsd-projects/txt-sysinstall/txt-sysinstall.h	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/txt-sysinstall.h	2010-10-12 21:04:39 UTC (rev 7781)
@@ -105,14 +105,6 @@
 
 #define	notnull(x)	(x != NULL && x[0] != 0)
 
-struct dialog_state {
-	char *name;
-	int (*dialog)(void *);
-	void *args;
-	void (*free_args)(void *);
-	STAILQ_ENTRY(dialog_state) entries;
-};
-
 struct disk_info {
 	char *disk;
 	char *desc;
@@ -138,21 +130,24 @@
 
 /* dialogs */
 void		sysinstall(void);
-int			dialog_sysinstall(void *);
-int			dialog_disksel(void *);
-int			dialog_useradd(void *);
-int			dialog_netif(void *);
-int			dialog_rootpass(void *);
-int			dialog_partsel(void *);
-int			dialog_tzone(void *);
-int			dialog_components(void *);
-int			dialog_medium(void *);
-int			dialog_label(void *);
-int			dialog_ftp(void *);
-int			dialog_packages(void *);
+int			dialog_sysinstall(void);
+int			dialog_disksel(void);
+int			dialog_useradd(void);
+int			dialog_netif(void);
+int			dialog_rootpass(void);
+int			dialog_partsel(void);
+int			dialog_tzone(void);
+int			dialog_components(void);
+int			dialog_medium(void);
+int			dialog_label(void);
+int			dialog_ftp(void);
+int			dialog_packages(void);
 void		dialog_busy(int, int, const char *);
 void		do_install(void);
 
+void		dialog_bootloader(void);
+void		dialog_mirror(void);
+
 /* utility functions */
 void		sysinstall_init(void);
 void		sysinstall_fini(void);
@@ -171,10 +166,50 @@
 struct disk_info *get_disk_info_by_disk(const char *);
 void		free_disk_info(void *);
 
-struct dialog_state *get_next_dialog(void);
-struct dialog_state *get_dialog_by_name(const char *);
-struct dialog_state *get_prev_dialog(void);
-void set_next_dialog(const char *, int (*)(void *), void *, void (*)(void *));
+struct disk_info *set_current_disk(struct disk_info *);
+struct disk_info *get_current_disk(void);
 
 struct disk_list *get_disk_list(void);
 void	free_disk_list(void);
+
+#define	installType(x)          appendconfig("installType", x)
+#define	installMode(x)          appendconfig("installMode", x)
+#define	installMedium(x)        appendconfig("installMedium", x)
+
+#define	installComponents(x)    appendconfig("installComponents", x)
+#define	installPackages(x)      appendconfig("installPackages", x)
+
+#define	packageType(x)          appendconfig("packageType", x)
+
+#define	rootPass(x)             appendconfig("rootPass", x)
+#define encpass(x)				appendconfig("encpass", x)
+
+#define	userName(x)             appendconfig("userName", x)
+#define	userComment(x)          appendconfig("userComment", x)
+#define	userPass(x)             appendconfig("userPass", x)
+#define	userGroups(x)           appendconfig("userGroups", x)
+#define	userShell(x)            appendconfig("userShell", x)
+#define	autoLoginUser(x)        appendconfig("autoLoginUser", x)
+#define	commitUser()            appendconfig("commitUser", NULL)
+
+#define	partition(x)            appendconfig("partition", x)
+#define	bootManager(x)          appendconfig("bootManager", x)
+
+#define	mirror(x)               appendconfig("mirror", x)
+#define	mirrorbal(x)            appendconfig("mirrorbal", x)
+
+#define	ftpPath(x)              appendconfig("ftpPath", x)
+
+#define	timeZone(x)             appendconfig("timeZone", x) 
+
+#define	enableNTP(x)            appendconfig("enableNTP", x)
+
+#define	disk(n,x) \
+do { \
+	char dp[16]; \
+	snprintf(dp, sizeof(dp), "disk%d-part", n); \
+	appendconfig(dp, x); \
+} while (0)
+
+#define	commitDiskPart()        appendconfig("commitDiskPart", NULL)
+#define	commitDiskLabel()       appendconfig("commitDiskLabel", NULL)

Modified: pcbsd-projects/txt-sysinstall/tzone.c
===================================================================
--- pcbsd-projects/txt-sysinstall/tzone.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/tzone.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -48,13 +48,13 @@
 		place = self->title;
 
 	snprintf(tzone, sizeof(tzone), "%s/%s", self->prompt, place);
-	appendconfig("timeZone", tzone);
+	timeZone(tzone);
 
 	return (0);
 }
 
 int
-dialog_tzone(void *args)
+dialog_tzone(void)
 {
 	char *token;
 	char *buf;
@@ -87,10 +87,8 @@
 	ntp = dialog_yesno("Network Time Protocol",
 	    "Do you want to enable NTP (automatic time synchronization) ?",
 	    5, 70);
-	if (ntp == FALSE) {
-		appendconfig("enableNTP", "yes");
-	}
+	if (ntp == FALSE)
+		enableNTP("yes");
 
-	set_next_dialog("medium", &dialog_medium, NULL, NULL);
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/useradd.c
===================================================================
--- pcbsd-projects/txt-sysinstall/useradd.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/useradd.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -46,7 +46,7 @@
 }
 
 int
-dialog_useradd(void *args)
+dialog_useradd(void)
 {
 	unsigned char username[64], realname[64];
 	unsigned char password1[64];
@@ -100,18 +100,17 @@
 		screen_clear(MODULE);
 		add = dialog_yesno("Add user", prompt, 10, 60);
 		if (add == FALSE) {
-			appendconfig("userName", username);
-			appendconfig("userComment", realname);
-			appendconfig("userPass", password2);
-			appendconfig("userGroups", "wheel,operator");
-			appendconfig("autoLoginUser", username);
-			appendconfig("userShell", shellPath);
-			appendconfig("commitUser", NULL);
+			userName(username);
+			userComment(realname);
+			userPass(password2);
+			userGroups("wheel,operator");
+			autoLoginUser(username);
+			userShell(shellPath);
+			commitUser();
 		} else {
 			goto useradd_restart;
 		}
 	}
 
-	set_next_dialog("rootpass", &dialog_rootpass, NULL, NULL);
 	return (0);
 }

Modified: pcbsd-projects/txt-sysinstall/util.c
===================================================================
--- pcbsd-projects/txt-sysinstall/util.c	2010-10-12 18:22:17 UTC (rev 7780)
+++ pcbsd-projects/txt-sysinstall/util.c	2010-10-12 21:04:39 UTC (rev 7781)
@@ -50,62 +50,27 @@
 };
 STAILQ_HEAD(confighead, config) configlist;
 
-STAILQ_HEAD(dialog_state_head, dialog_state) dialog_state_list;
-
 static struct disk_list DISK_LIST;
+static struct disk_info *CURRENT_DISK;
 
-
-struct dialog_state *
-get_next_dialog(void)
+struct disk_info *
+set_current_disk(struct disk_info *di)
 {
-	return (STAILQ_FIRST(&dialog_state_list));
-}
+	struct disk_info *temp;
 
-struct dialog_state *
-get_dialog_by_name(const char *name)
-{
-	struct dialog_state *ds;
+	temp = CURRENT_DISK;
+	CURRENT_DISK = di;
 
-	STAILQ_FOREACH(ds, &dialog_state_list, entries) {
-		if (strcmp(ds->name, name) == 0)
-			return (ds);
-	}
-
-	return (NULL);
+	return (temp);
 }
 
-struct dialog_state *
-get_prev_dialog(void)
+struct disk_info *
+get_current_disk(void)
 {
-	struct dialog_state *first;
-	struct dialog_state *prev;
-
-	prev = NULL;
-	first = STAILQ_FIRST(&dialog_state_list);
-	if (first) {
-		prev = STAILQ_NEXT(first, entries);
-	}
-
-	return (prev);
+	return (CURRENT_DISK);
 }
 
 void
-set_next_dialog(const char *name, int (*next)(void *),
-	void *args, void (*free_args)(void *))
-{
-	struct dialog_state *ds;
-
-	ds = safe_malloc(sizeof(*ds));
-	ds->name = safe_strdup(name);
-	ds->dialog = next;
-	ds->args = args;
-	ds->free_args = free_args;
-
-	STAILQ_INSERT_HEAD(&dialog_state_list, ds, entries);
-}
-
-
-void
 screen_clear(const char *module)
 {
 	dialog_clear();
@@ -348,17 +313,13 @@
 sysinstall_init(void)
 {
 	STAILQ_INIT(&configlist);
-	STAILQ_INIT(&dialog_state_list);
 	get_disk_list();
-
-	set_next_dialog("sysinstall", &dialog_sysinstall, NULL, NULL);
 }
 
 void
 sysinstall_fini(void)
 {
 	struct config *c, *c_temp;
-	struct dialog_state *ds, *ds_temp;
 
 	free_disk_list();
 
@@ -368,14 +329,6 @@
 		free(c->value);
 		free(c);
 	}
-
-	STAILQ_FOREACH_SAFE(ds, &dialog_state_list, entries, ds_temp) {
-		STAILQ_REMOVE(&dialog_state_list, ds, dialog_state, entries);
-		if (ds->free_args != NULL)
-			ds->free_args(ds->args);
-		free(ds->name);
-		free(ds);
-	}
 }
 
 void



More information about the Commits mailing list