[svn-commits] kpfleming: trunk r405 - /trunk/menuselect.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 5 10:14:22 CST 2008


Author: kpfleming
Date: Mon Nov  3 06:25:37 2008
New Revision: 405

URL: http://svn.digium.com/view/menuselect?view=rev&rev=405
Log:
allow the menuselect-deps file to hold the 'previously met' state for each item as well, and also to support a 'disabled' value for when the user has explicitly disabled an item (work in progress)


Modified:
    trunk/menuselect.c

Modified: trunk/menuselect.c
URL: http://svn.digium.com/view/menuselect/trunk/menuselect.c?view=diff&rev=405&r1=404&r2=405
==============================================================================
--- trunk/menuselect.c (original)
+++ trunk/menuselect.c Mon Nov  3 06:25:37 2008
@@ -77,10 +77,18 @@
 /*! Menu name */
 const char *menu_name = "Menuselect";
 
+enum dep_file_state {
+	DEP_FILE_UNKNOWN = -2,
+	DEP_FILE_DISABLED = -1,
+	DEP_FILE_UNMET = 0,
+	DEP_FILE_MET = 1,
+};
+
 /*! Global list of dependencies that are external to the tree */
 struct dep_file {
 	char name[32];
-	int met;
+	enum dep_file_state met;
+	enum dep_file_state previously_met;
 	AST_LIST_ENTRY(dep_file) list;
 } *dep_file;
 AST_LIST_HEAD_NOLOCK_STATIC(deps_file, dep_file);
@@ -372,7 +380,7 @@
 				mem->depsfailed = HARD_FAILURE;
 				AST_LIST_TRAVERSE(&deps_file, dep_file, list) {
 					if (!strcasecmp(dep_file->name, dep->name)) {
-						if (dep_file->met)
+						if (dep_file->met == DEP_FILE_MET)
 							mem->depsfailed = NO_FAILURE;
 						break;
 					}
@@ -451,7 +459,7 @@
 				mem->conflictsfailed = NO_FAILURE;
 				AST_LIST_TRAVERSE(&deps_file, dep_file, list) {
 					if (!strcasecmp(dep_file->name, cnf->name)) {
-						if (dep_file->met)
+						if (dep_file->met == DEP_FILE_MET)
 							mem->conflictsfailed = HARD_FAILURE;
 						break;
 					}
@@ -510,7 +518,6 @@
 {
 	FILE *f;
 	char buf[80];
-	char *p;
 	int res = 0;
 
 	if (!(f = fopen(MENUSELECT_DEPS, "r"))) {
@@ -520,14 +527,57 @@
 
 	/* Build a dependency list from the file generated by configure */	
 	while (memset(buf, 0, sizeof(buf)), fgets(buf, sizeof(buf), f)) {
+		char *name, *cur, *prev, *p;
+		int val;
+
 		p = buf;
-		strsep(&p, "=");
+		name = strsep(&p, "=");
+
 		if (!p)
 			continue;
+
+		cur = strsep(&p, ":");
+		prev = strsep(&p, ":");
+
 		if (!(dep_file = calloc(1, sizeof(*dep_file))))
 			break;
-		strncpy(dep_file->name, buf, sizeof(dep_file->name) - 1);
-		dep_file->met = atoi(p);
+
+		strncpy(dep_file->name, name, sizeof(dep_file->name) - 1);
+		dep_file->met = DEP_FILE_UNKNOWN;
+		dep_file->previously_met = DEP_FILE_UNKNOWN;
+
+		if (sscanf(cur, "%d", &val) != 1) {
+			fprintf(stderr, "Unknown value '%s' found in %s for %s\n", cur, MENUSELECT_DEPS, name);
+		} else {
+			switch (val) {
+			case DEP_FILE_MET:
+			case DEP_FILE_UNMET:
+			case DEP_FILE_DISABLED:
+				dep_file->met = val;
+				break;
+			default:
+				fprintf(stderr, "Unknown value '%s' found in %s for %s\n", cur, MENUSELECT_DEPS, name);
+				break;
+			}
+		}
+
+		if (prev) {
+			if (sscanf(prev, "%d", &val) != 1) {
+				fprintf(stderr, "Unknown value '%s' found in %s for %s\n", prev, MENUSELECT_DEPS, name);
+			} else {
+				switch (val) {
+				case DEP_FILE_MET:
+				case DEP_FILE_UNMET:
+				case DEP_FILE_DISABLED:
+					dep_file->previously_met = val;
+					break;
+				default:
+					fprintf(stderr, "Unknown value '%s' found in %s for %s\n", prev, MENUSELECT_DEPS, name);
+					break;
+				}
+			}
+		}
+
 		AST_LIST_INSERT_TAIL(&deps_file, dep_file, list);
 	}
 




More information about the svn-commits mailing list