PERFORCE change 166959 for review

David Forsythe dforsyth at FreeBSD.org
Mon Aug 3 07:59:38 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166959

Change 166959 by dforsyth at squirrel on 2009/08/03 07:58:58

	Start building pkg_info.

Affected files ...

.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#41 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#36 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_command.c#3 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_db.c#9 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_db_hierdb.c#7 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_db_hierdb_read.c#3 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_error.h#4 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_file.c#12 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest.c#3 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest.h#3 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest_plist.c#3 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_util.c#16 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_util.h#13 edit
.. //depot/projects/soc2009/dforsyth_libpkg/pkg_info/main.c#27 edit
.. //depot/projects/soc2009/dforsyth_libpkg/pkg_info/pkg_info.h#8 edit

Differences ...

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#41 (text+ko) ====

@@ -109,7 +109,7 @@
 pkg_name(struct pkg *p)
 {
 	pkg_check_magic(p, __func__);	
-	if (pkg_parse_manifest(p) != OK)
+	if (pkg_parse_manifest(p) != PKG_OK)
 		return (NULL);
 	
 	return (pkg_manifest_name(p->pm));
@@ -122,7 +122,7 @@
 pkg_origin(struct pkg *p)
 {
 	pkg_check_magic(p, __func__);
-	if (p->in_db != NULL && (pkg_parse_manifest(p) & NOT_OK))
+	if (p->in_db != NULL && (pkg_parse_manifest(p) & PKG_NOT_OK))
 		return (NULL);
 
 	return (pkg_manifest_origin(p->pm));
@@ -156,9 +156,9 @@
 
 	pkg_check_magic(p, __func__);
 	
-	status = OK;
+	status = PKG_OK;
 	status |= pkg_manifest_set_name(p->pm, name);
-	if (status != OK || p->in_db == NULL)
+	if (status != PKG_OK || p->in_db == NULL)
 		return (status);
 	/* Update manifest in db. */
 	return (status);
@@ -173,9 +173,9 @@
 
 	pkg_check_magic(p, __func__);
 
-	status = OK;
+	status = PKG_OK;
 	status |= pkg_manifest_set_origin(p->pm, origin);
-	if (status != OK || p->in_db == NULL)
+	if (status != PKG_OK || p->in_db == NULL)
 		return (status);
 	/* Update manifest in db. */
 	return (status);
@@ -208,7 +208,7 @@
 		return (p->description);
 	
 	if (p->description == NULL && 
-		pkg_read_pkg_element_from_db(p, PKG_ELEM_DESCRIPTION) != OK)
+		pkg_read_pkg_element_from_db(p, PKG_ELEM_DESCRIPTION) != PKG_OK)
 		return (NULL);
 	return (p->description);
 }
@@ -288,7 +288,7 @@
 	pkg_check_magic(src, __func__);
 	pkg_check_magic(dest, __func__);
 
-	status = OK;
+	status = PKG_OK;
 	pkg_reset(dest);
 	status |= pkg_set_ident(dest, src->ident);
 	status |= pkg_set_comment(dest, src->comment);
@@ -298,7 +298,7 @@
 		return (status);
 	pm = pkg_manifest_new();
 	if (pm == NULL)
-		status |= MEMORY_ERR;
+		status |= PKG_MEMORY_ERR;
 	else {
 		status |= pkg_manifest_clone(pm, src->pm);
 		dest->pm = pm;
@@ -346,6 +346,26 @@
 	return (pkg_manifest_pkg_conflict_list(p->pm));
 }
 
+const char *const *
+pkg_execs(struct pkg *p)
+{
+	pkg_check_magic(p, __func__);
+	if (p->pm == NULL && p->in_db != NULL)
+		pkg_parse_manifest(p);
+
+	return (pkg_manifest_install_pkg_command_list(p->pm));
+}
+
+const char *const *
+pkg_unexecs(struct pkg *p)
+{
+	pkg_check_magic(p, __func__);
+	if (p->pm == NULL && p->in_db != NULL)
+		pkg_parse_manifest(p);
+
+	return (pkg_manifest_deinstall_pkg_command_list(p->pm));
+}
+
 /* Add a file to a package. This is fairly useless at this point
  * because... well, there the hell is the file coming from? */
 
@@ -359,7 +379,7 @@
 
 	/* TODO: Add some sanity checks in here. */
 	
-	status = OK;
+	status = PKG_OK;
 	pkg_parse_manifest(p);
 	status |= pkg_manifest_insert_pkg_file(p->pm, path, md5, cwd, mode, owner, group);
 
@@ -481,12 +501,12 @@
 	
 	/* Manifest has been parsed already. */
 	if (p->pm != NULL)
-		return (OK);
+		return (PKG_OK);
 	
-	status = OK;
+	status = PKG_OK;
 	p->pm = pkg_manifest_new();
 	if (p->pm == NULL) 
-		return (MEMORY_ERR | NOT_OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
 	pkg_manifest_reset(p->pm);
 	if (p->in_db != NULL) {
 		status |= pkg_read_pkg_element_from_db(p, PKG_ELEM_MANIFEST);
@@ -511,7 +531,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->ident = ident_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -519,7 +539,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->comment = comment_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -527,7 +547,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->description = description_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -535,7 +555,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->display = display_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -543,7 +563,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->required_by = required_by_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -551,7 +571,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->mtree_dirs = mtree_dirs_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -559,7 +579,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->pm = pm_ptr;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -567,7 +587,7 @@
 {
 	pkg_check_magic(p, __func__);
 	p->in_db = db;
-	return (OK);
+	return (PKG_OK);
 }
 
 int

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#36 (text+ko) ====

@@ -14,9 +14,9 @@
 
 /* General Errors. */
 
-#define OK					0x00000000
-#define NOT_OK				0x00000001
-#define MEMORY_ERR			0x00000002
+#define PKG_OK					0x00000000
+#define	PKG_NOT_OK				0x00000001
+#define PKG_MEMORY_ERR			0x00000002
 
 #define FOREACH_PKG_IN_DB(p, db, list) \
 	while (*list != NULL && (p = pkg_db_select_pkg(db, *list++)))
@@ -57,6 +57,8 @@
 const char *const *pkg_files(struct pkg *p);
 const char *const *pkg_depends(struct pkg *p);
 const char *const *pkg_conflicts(struct pkg *p);
+const char *const *pkg_execs(struct pkg *p);
+const char *const *pkg_unexecs(struct pkg *p);
 
 int pkg_insert_pkg_file(struct pkg *p, const char *path, const char *cwd, 
 	const char *group, const char *md5, const char *mode, 

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_command.c#3 (text+ko) ====

@@ -61,7 +61,7 @@
 {
 	pkg_command_check_magic(pe, __func__);
 	pe->type = type;
-	return (OK);
+	return (PKG_OK);
 }
 
 int

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_db.c#9 (text+ko) ====

@@ -53,7 +53,7 @@
 	int status;
 
 	if (db->open)
-		return (OK);
+		return (PKG_OK);
 	
 	db->db_type = db_type;
 	
@@ -68,7 +68,7 @@
 		break;
 	default:
 		/* Bad type. */
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 	}
 
 	return (db->pkg_db_db_open(db, db_root));
@@ -84,7 +84,7 @@
 
 	db->open = 0;
 
-	return (OK);
+	return (PKG_OK);
 }
 
 void 
@@ -130,7 +130,7 @@
 	pkg_db_check_magic(db, __func__);
 	/* do work. */
 
-	return (OK);
+	return (PKG_OK);
 }
 
 /* Copy a package into a database. */
@@ -141,7 +141,6 @@
 	int status;
 	char **list;
 	struct pkg *entries;
-
 	if (db->pkg_count % 10 == 0) {
 		entries = db->pkg_entries;
 		list = db->pkg_list;

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_db_hierdb.c#7 (text+ko) ====

@@ -40,31 +40,31 @@
 	
 
 	if (db->open)
-		return (OK);
+		return (PKG_OK);
 
 	status = lstat(db_root, &sb);
 	if (status < 0 || !S_ISDIR(sb.st_mode) || S_ISLNK(sb.st_mode))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	db->db_root = strdup(db_root);
 	if (db->db_root == NULL)
-		return (NOT_OK | MEMORY_ERR);
+		return (PKG_NOT_OK | PKG_MEMORY_ERR);
 
-	status = OK;
+	status = PKG_OK;
 	c = scandir(db->db_root, &ents, pkg_dir_select, alphasort);
 	if (c < 1)
-		return (NOT_OK | MEMORY_ERR);
+		return (PKG_NOT_OK | PKG_MEMORY_ERR);
 
 	p = pkg_new();
 	for (i = 0; i < c; ++i) {
 		status |= pkg_set_ident(p, ents[i]->d_name);
 		status |= pkg_db_insert_pkg_entry(db, p);
-		if (status & NOT_OK) {
+		if (status & PKG_NOT_OK) {
 			pkg_db_clear_pkg_entries(db);
 			for (; i < c; ++i)
 				free(ents[i]);
 			free(ents);
-			return (NOT_OK | MEMORY_ERR);
+			return (PKG_NOT_OK | PKG_MEMORY_ERR);
 		}
 		free(ents[i]);
 		pkg_reset(p);
@@ -89,10 +89,10 @@
 	char *path;
 	int status;
 
-	status = OK;
+	status = PKG_OK;
 	ident = pkg_ident(p);
 	if (ident == NULL)
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	path = path_build(ident, COMMENT_FILE);
 	status |= pkg_set_comment(p,pkg_db_hierdb_read_file_to_text(db, path));

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_db_hierdb_read.c#3 (text+ko) ====

@@ -43,7 +43,7 @@
 {
 	int status;
 	
-	status = OK;
+	status = PKG_OK;
 	switch (element) {
 	case (PKG_ELEM_COMMENT):
 		status = pkg_db_hierdb_read_comment_to_pkg(db, p);
@@ -64,7 +64,7 @@
 		status = pkg_db_hierdb_read_required_by_to_pkg(db, p);
 		break;
 	default:
-		status = NOT_OK;
+		status = PKG_NOT_OK;
 		break;
 	}
 
@@ -99,7 +99,7 @@
 	char *text;
 	struct stat sb;
 	
-	status = OK;
+	status = PKG_OK;
 	dir = path_build(db->db_root, p->ident);
 	path = path_build(dir, filename);
 
@@ -145,16 +145,16 @@
 	char *text;
 
 	if (!pkg_db_hierdb_file_exists(db, p, COMMENT_FILE))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	text = pkg_db_hierdb_read_file_to_text(db, p, COMMENT_FILE);
 	if (text == NULL)
-		return (MEMORY_ERR | NOT_OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
 	
 	pkg_util_trim_newline(text);
 	__pkg_set_comment_ptr(p, text);
 
-	return (OK);
+	return (PKG_OK);
 }
 
 static int
@@ -163,16 +163,16 @@
 	char *text;
 	
 	if (!pkg_db_hierdb_file_exists(db, p, DESCRIPTION_FILE))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	text = pkg_db_hierdb_read_file_to_text(db, p, DESCRIPTION_FILE);
 	if (text == NULL)
-		return (MEMORY_ERR | NOT_OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
 
 	pkg_util_trim_newline(text);
 	__pkg_set_description_ptr(p, text);
 
-	return (OK);
+	return (PKG_OK);
 }
 
 static int
@@ -181,16 +181,16 @@
 	char *text;
 	
 	if (!pkg_db_hierdb_file_exists(db, p, DISPLAY_FILE))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	text = pkg_db_hierdb_read_file_to_text(db, p, DISPLAY_FILE);
 	if (text == NULL)
-		return (MEMORY_ERR | NOT_OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
 
 	pkg_util_trim_newline(text);
 	__pkg_set_display_ptr(p, text);
 
-	return (OK);
+	return (PKG_OK);
 }
 
 static int 
@@ -199,16 +199,16 @@
 	char *text;
 
 	if (!pkg_db_hierdb_file_exists(db, p, MTREE_DIRS_FILE))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	text = pkg_db_hierdb_read_file_to_text(db, p, MTREE_DIRS_FILE);
 	if (text == NULL)
-		return (MEMORY_ERR | NOT_OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
 
 	pkg_util_trim_newline(text);
 	__pkg_set_mtree_dirs_ptr(p, text);
 
-	return (OK);
+	return (PKG_OK);
 }
 
 static int 
@@ -217,22 +217,21 @@
 	char *text;
 
 	if (!pkg_db_hierdb_file_exists(db, p, REQUIRED_BY_FILE))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	text = pkg_db_hierdb_read_file_to_text(db, p, REQUIRED_BY_FILE);
 	if (text == NULL)
-		return (MEMORY_ERR | NOT_OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
 
 	pkg_util_trim_newline(text);
 	__pkg_set_required_by_ptr(p, text);
 
-	return (OK);
+	return (PKG_OK);
 }
 
 static int
 pkg_db_hierdb_read_pkg_manifest_to_pkg(struct pkg_db *db, struct pkg *p)
 {
-	char *text;
 	FILE *manifest_stream;
 	int manifest_type;
 	int status;
@@ -241,11 +240,11 @@
 
 	/* Assume PLIST for now, because I want to go to sleep. */
 	if (!pkg_db_hierdb_file_exists(db, p, CONTENTS_FILE))
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 
 	/* Open a stream. */
 	manifest_stream = pkg_db_hierdb_open_file_stream_read(db, p, CONTENTS_FILE);
-	status = OK;	
+	status = PKG_OK;	
 	switch(manifest_type) {
 	case (PLIST):
 		status = pkg_manifest_parse_plist_from_stream(p->pm, manifest_stream);

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_error.h#4 (text+ko) ====

@@ -1,9 +1,9 @@
 #ifndef __PKG_ERROR_H__
 #define __PKG_ERROR_H__
 
-#define OK					0x00000000
-#define NOT_OK				0x00000001
-#define MEMORY_ERR			0x00000002
+#define PKG_OK					0x00000000
+#define PKG_NOT_OK				0x00000001
+#define PKG_MEMORY_ERR			0x00000002
 
 void pkg_error_msg(const char *errmsg);
 

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_file.c#12 (text+ko) ====

@@ -153,7 +153,7 @@
 {
 	pkg_file_check_magic(pf, __func__);
 	pf->ignore = 1;
-	return (OK);
+	return (PKG_OK);
 }
 
 int
@@ -161,7 +161,7 @@
 {
 	pkg_file_check_magic(pf, __func__);
 	pf->ignore = 0;
-	return (OK);
+	return (PKG_OK);
 }
 
 int

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest.c#3 (text+ko) ====

@@ -208,6 +208,18 @@
 	return ((const char *const *)pm->pkg_file_list);
 }
 
+const char *const *
+pkg_manifest_install_pkg_command_list(struct pkg_manifest *pm)
+{
+	return ((const char *const *)pm->pkg_install_list);
+}
+
+const char *const *
+pkg_manifest_deinstall_pkg_command_list(struct pkg_manifest *pm)
+{
+	return ((const char *const *)pm->pkg_deinstall_list);
+}
+
 int
 pkg_manifest_insert_pkg_conflict(struct pkg_manifest *pm, const char *name, 
 	const char *version)
@@ -230,11 +242,11 @@
 		if (pm->pkg_conflict_list == NULL || pm->pkg_conflict_entries == NULL) {
 			pm->pkg_conflict_list = list;
 			pm->pkg_conflict_entries = conflicts;
-			return (MEMORY_ERR | NOT_OK);
+			return (PKG_MEMORY_ERR | PKG_NOT_OK);
 		}
 	}
 
-	status = OK;
+	status = PKG_OK;
 
 	pc = &pm->pkg_conflict_entries[pm->pkg_conflict_count];
 	pkg_conflict_init(pc);
@@ -269,11 +281,11 @@
 		if (pm->pkg_depend_list == NULL || pm->pkg_depend_entries == NULL) {
 			pm->pkg_depend_list = list;
 			pm->pkg_depend_entries = depends;
-			return (MEMORY_ERR | NOT_OK);
+			return (PKG_MEMORY_ERR | PKG_NOT_OK);
 		}
 	}
 
-	status = OK;
+	status = PKG_OK;
 
 
 	pd = &pm->pkg_depend_entries[pm->pkg_depend_count];
@@ -312,11 +324,11 @@
 		if (pm->pkg_file_list == NULL || pm->pkg_file_entries == NULL) {
 			pm->pkg_file_list = list;
 			pm->pkg_file_entries = files;
-			return (MEMORY_ERR | NOT_OK);
+			return (PKG_MEMORY_ERR | PKG_NOT_OK);
 		}
 	}
 
-	status = OK;
+	status = PKG_OK;
 
 	pf = &pm->pkg_file_entries[pm->pkg_file_count];
 	pkg_file_init(pf);
@@ -333,16 +345,84 @@
 	return (status);
 }
 
+/* XXX: This method of storing commands is pretty much unacceptable.  Take a look at
+ * previous attempts at a package library or try to devise a new way of storing this
+ * information. */
+
 int
 pkg_manifest_insert_install_pkg_command(struct pkg_manifest *pm, int type, 
 	const char *argument) {
-	return (0);
+	int status;
+	char **list;
+	struct pkg_command *commands;
+	struct pkg_command *pe;
+
+	if (argument == NULL) {
+		pkg_error_msg("");
+		rage_quit();
+	}
+
+	if (pm->pkg_install_count % 10 == 0) {
+		list = pm->pkg_install_list;
+		commands = pm->pkg_install_entries;
+		pm->pkg_install_list = realloc(list, sizeof(*list) * (pm->pkg_install_count + 11));
+		pm->pkg_install_entries = realloc(commands, sizeof(*commands) * (pm->pkg_install_count + 11));
+		if (pm->pkg_install_list == NULL || pm->pkg_install_entries == NULL) {
+			pm->pkg_install_list = list;
+			pm->pkg_install_entries = commands;
+			return (PKG_MEMORY_ERR | PKG_NOT_OK);
+		}
+	}
+
+	status = PKG_OK;
+
+	pe = &pm->pkg_install_entries[pm->pkg_install_count];
+	pkg_command_init(pe);
+	status |= pkg_command_set_type(pe, type);
+	status |= pkg_command_set_argument(pe, argument);
+
+	pm->pkg_install_list[pm->pkg_install_count++] = pkg_command_argument(pe);
+	pm->pkg_install_list[pm->pkg_install_count] = NULL;
+
+	return (status);
 }
 
 int
 pkg_manifest_insert_deinstall_pkg_command(struct pkg_manifest *pm, int type,
 	const char *argument) {
-	return (0);
+	int status;
+	char **list;
+	struct pkg_command *commands;
+	struct pkg_command *pe;
+
+	if (argument == NULL) {
+		pkg_error_msg("");
+		rage_quit();
+	}
+
+	if (pm->pkg_deinstall_count % 10 == 0) {
+		list = pm->pkg_deinstall_list;
+		commands = pm->pkg_deinstall_entries;
+		pm->pkg_deinstall_list = realloc(list, sizeof(*list) * (pm->pkg_deinstall_count + 11));
+		pm->pkg_deinstall_entries = realloc(commands, sizeof(*commands) * (pm->pkg_deinstall_count + 11));
+		if (pm->pkg_deinstall_list == NULL || pm->pkg_deinstall_entries == NULL) {
+			pm->pkg_deinstall_list = list;
+			pm->pkg_deinstall_entries = commands;
+			return (PKG_MEMORY_ERR | PKG_NOT_OK);
+		}
+	}
+
+	status = PKG_OK;
+
+	pe = &pm->pkg_deinstall_entries[pm->pkg_deinstall_count];
+	pkg_command_init(pe);
+	status |= pkg_command_set_type(pe, type);
+	status |= pkg_command_set_argument(pe, argument);
+
+	pm->pkg_deinstall_list[pm->pkg_deinstall_count++] = pkg_command_argument(pe);
+	pm->pkg_deinstall_list[pm->pkg_deinstall_count] = NULL;
+
+	return (status);
 }
 
 void

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest.h#3 (text+ko) ====

@@ -150,6 +150,10 @@
 
 const char *const *pkg_manifest_pkg_file_list(struct pkg_manifest *pm);
 
+const char *const *pkg_manifest_install_pkg_command_list(struct pkg_manifest *pm);
+
+const char *const *pkg_manifest_deinstall_pkg_command_list(struct pkg_manifest *pm);
+
 struct pkg_conflict *pkg_manifest_select_pkg_conflict(struct pkg_manifest *pm, const char *name);
 
 struct pkg_depend *pkg_manifest_select_pkg_depend(struct pkg_manifest *pm, const char *name);

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_manifest_plist.c#3 (text+ko) ====

@@ -104,13 +104,14 @@
 	char *p;
 	char *line;
 	char *buff;
+	char *buffp;
 	struct plist_parse_state st;
 	int status;
 	
-	status = OK;
+	status = PKG_OK;
 	pkg_manifest_reset(pm);
 	parse_state_set_default(&st);
-	buff = strdup(manifest_text);
+	buffp = buff = strdup(manifest_text);
 	/* TODO: If we keep this, write a getline function for it. */
 	for (p = buff; *p != '\0'; p++) {
 		if (*p == '\n') {
@@ -118,7 +119,7 @@
 			line[p - buff] = '\0';
 			status = pkg_manifest_parse_plist_parse_line(pm, line, &st);
 			/*
-			if (status != OK) {
+			if (status != PKG_OK) {
 				pkg_manifest_reset(pm);
 				free(buff);
 				return (status);
@@ -127,7 +128,7 @@
 			buff = p + 1;
 		}
 	}
-	// free(buff);
+	free(buffp);
 
 	return (0);
 }
@@ -139,19 +140,19 @@
 	struct plist_parse_state st;
 	int status;
 	
-	status = OK;
+	status = PKG_OK;
 	pkg_manifest_reset(pm);
 	parse_state_set_default(&st);
 	while (fgets(line, LINE_MAX, manifest_stream) != NULL) {
 		status |= pkg_manifest_parse_plist_parse_line(pm, line, &st);
-		/*
-		if (status != OK) {
-			printf("bad line: %s\n", line);
+		if (status != PKG_OK) {
+			/* TODO: Do something usefull here. */
+			fprintf(stderr, "bad line: %s\n", line);
 		}
-		*/
+		
 	}
 
-	return (OK);
+	return (PKG_OK);
 }
 
 static int
@@ -214,7 +215,7 @@
 	struct pkg_file *lpf;
 	struct pkg_depend *lpd;
 	
-	status = OK;
+	status = PKG_OK;
 	argc = sscanf(line, "%s %[^\n]", cmd, argument);
 	if (argc == 1 && line[0] != PLIST_PRE_CMD) {
 		cmd_id = PM_FILE;
@@ -222,7 +223,7 @@
 	else if (line[0] == PLIST_PRE_CMD)
 		cmd_id = pkg_manifest_parse_plist_identify_plist_cmd(cmd + 1);
 	else {
-		return (NOT_OK);
+		return (PKG_NOT_OK);
 	}
 	
 	if (cmd_id < PM_COMMENT) {
@@ -242,7 +243,7 @@
 		}
 		if (strlen(argument) == 0) {
 			pkg_error_msg("emtpy srdir command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_util_strdup(isolate, &pm->srcdir);
@@ -250,7 +251,7 @@
 	case (PM_EXEC):
 		if (strlen(argument) == 0) {
 			pkg_error_msg("empty exec");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_manifest_insert_install_pkg_command(pm, PM_EXEC, argument);
@@ -258,7 +259,7 @@
 	case (PM_UNEXEC):
 		if (strlen(argument) == 0) {
 			pkg_error_msg("empty exec");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_manifest_insert_deinstall_pkg_command(pm, PM_UNEXEC, argument);
@@ -270,7 +271,7 @@
 	case (PM_OPTION):
 		if (strlen(argument) == 0) {
 			pkg_error_msg("empty option.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		if (strcmp(isolate, PLIST_OPTION_EXTRACT_IN_PLACE) == 0)
@@ -281,7 +282,7 @@
 			pm->preserve = 1;
 		else {
 			pkg_error_msg("bad option.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 		}
 		break;
 	case (PM_OWNER):
@@ -306,7 +307,7 @@
 		/* Do not support pkg names with spaces. */
 		if (strlen(isolate) == 0) {
 			pkg_error_msg("empty name command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_util_strdup(isolate, &pm->name);
@@ -314,7 +315,7 @@
 	case (PM_DIRRM):
 		if (strlen(isolate) == 0) {
 			pkg_error_msg("empty dirrm command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_manifest_insert_deinstall_pkg_command(pm, PM_DIRRM, isolate);
@@ -322,7 +323,7 @@
 	case (PM_MTREE):
 		if (strlen(isolate) == 0) {
 			pkg_error_msg("empty mtree command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_util_strdup(isolate, &pm->mtree_file);
@@ -330,7 +331,7 @@
 	case (PM_DISPLAY):
 		if (strlen(isolate) == 0) {
 			pkg_error_msg("empty display command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_util_strdup(isolate, &pm->display_file);
@@ -338,7 +339,7 @@
 	case (PM_PKGDEP):
 		if (strlen(isolate) == 0) {
 			pkg_error_msg("empty pkgdep command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_manifest_insert_pkg_depend(pm, isolate, NULL);
@@ -347,7 +348,7 @@
 	case (PM_CONFLICTS):
 		if (strlen(isolate) == 0) {
 			pkg_error_msg("empty conflict command.");
-			status = NOT_OK;
+			status = PKG_NOT_OK;
 			break;
 		}
 		status = pkg_manifest_insert_pkg_conflict(pm, isolate, NULL);
@@ -363,12 +364,12 @@
 			} else if (sscanf(argument, "DEPORIGIN:%s %[^\n]", isolate, trail) >= 1) {
 				if (st->last_rel_depend == NULL) {
 					pkg_error_msg("misplaced meta comment: deporigin.");
-					status = NOT_OK;
+					status = PKG_NOT_OK;
 					break;
 				}
 				if (strlen(isolate) == 0) {
 					pkg_error_msg("empty meta comment: deporigin");
-					status = NOT_OK;
+					status = PKG_NOT_OK;
 					break;
 				}
 				lpd = pkg_manifest_select_pkg_depend(pm, st->last_rel_depend);
@@ -376,12 +377,12 @@
 			} else if (sscanf(argument, "MD5:%s %[^\n]", isolate, trail) >= 1) {
 				if (st->last_rel_file == NULL) {
 					pkg_error_msg("misplace meta comment: md5.");
-					status = NOT_OK;
+					status = PKG_NOT_OK;
 					break;
 				}
 				if (strlen(isolate) == 0) {
 					pkg_error_msg("empty meta comment: md5");
-					status = NOT_OK;
+					status = PKG_NOT_OK;
 					break;
 				}
 				lpf = pkg_manifest_select_pkg_file(pm, st->last_rel_file);
@@ -402,7 +403,7 @@
 	case (PM_UNKNOWN):
 	default:
 		/* Unidentified command. */
-		status = NOT_OK;
+		status = PKG_NOT_OK;
 		break;
 	}
 

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_util.c#16 (text+ko) ====

@@ -42,8 +42,8 @@
 {
 	*dest = (src != NULL) ? strdup(src) : NULL;
 	if (src != NULL && *dest == NULL)
-		return (MEMORY_ERR | NOT_OK);
-	return (OK);
+		return (PKG_MEMORY_ERR | PKG_NOT_OK);
+	return (PKG_OK);
 }
 
 int
@@ -110,6 +110,8 @@
 	const char *const *files;
 	const char *const *conflicts;
 	const char *const *depends;
+	const char *const *install_list;
+	const char *const *deinstall_list;
 
 	const char *ident;
 	const char *comment;
@@ -214,4 +216,18 @@
 	fprintf(stream, "\ndescription:\n");
 	fprintf(stream, "%s\n",
 		(desc != NULL ? desc : "None"));
+
+	/* For now, just to show that it works, dump the "keys" */
+	install_list = pkg_execs(p);
+	printf("\nEXEC:\n");
+	if (install_list != NULL)
+		while (*install_list != NULL)
+			printf("%s\n", *install_list++);
+	
+	deinstall_list = pkg_unexecs(p);
+	printf("\nUNEXEC:\n");
+	if (deinstall_list != NULL)
+		while (*deinstall_list != NULL)
+			printf("%s\n", *deinstall_list++);
+	printf("\n");
 }

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_util.h#13 (text+ko) ====

@@ -17,4 +17,10 @@
 
 void rage_quit(void);
 
+#define APPEND_TO_ARRAY_AND_LIST(struct_type, entries, list, tmp_entries, tmp_list, current_count, increase) \
+			tmp_list = list; \
+			tmp_entries = entries; \
+			list = realloc(tmp_list, sizeof(*tmp_list) * (current_count + increase)); \
+			entries = realloc(tmp_entries, sizeof(tmp_entries) * (current_count + increase));
+
 #endif

==== //depot/projects/soc2009/dforsyth_libpkg/pkg_info/main.c#27 (text+ko) ====

@@ -6,35 +6,23 @@
 #include "pkg.h"
 #include "pkg_info.h"
 
-/* DEBUG */
-short opt_debug_dump = 0; /* M */
+#define OK		0
+#define NOT_OK	1
+
+void perform_on_db(struct pkg_db *db);
+int print_pkg_information(struct pkg *p);

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list