PERFORCE change 185173 for review

David Forsythe dforsyth at FreeBSD.org
Thu Oct 28 06:07:34 UTC 2010


http://p4web.freebsd.org/@@185173?ac=10

Change 185173 by dforsyth at skunk on 2010/10/28 06:06:54

	Tabs to spaces, expose types so that I can use TAILQ_* instead of rolling my
	own queues, move api into pkg.h rather than spreading it between multiple
	headers.

Affected files ...

.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/Makefile#6 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/base.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.c#7 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.h#6 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/database_internal.h#5 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/depend.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/depend.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec_internal.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/file.c#5 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/file.h#5 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.c#6 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.h#6 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_plist.c#6 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_plist.h#5 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_ftp.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_ftp.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_path.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_repository_path.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/internal.h#4 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/logger.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/logger.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg.c#9 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg.h#8 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_internal.h#7 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_pkg.h#8 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/pkg_types.h#1 add
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/repository_internal.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/reqby.c#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/reqby.h#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/util.c#4 edit
.. //depot/projects/soc2010/dforsyth_libpkg/libpkg/util.h#4 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/lib/pkg_install.h#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_add/Makefile#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_add/pkg_add.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_add/pkg_add.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_delete/Makefile#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_delete/pkg_delete.c#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_dump/Makefile#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_dump/pkg_dump.c#5 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_dump/pkg_dump.h#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_info/Makefile#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_info/pkg_info.c#5 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_info/pkg_info.h#3 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_validate/Makefile#2 edit
.. //depot/projects/soc2010/dforsyth_libpkg/pkg_install/pkg_validate/validate.c#2 edit

Differences ...

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/Makefile#6 (text+ko) ====

@@ -11,15 +11,12 @@
 
 
 SRCS=	pkg.c \
-        database.c \
-        repository.c \
-        freebsd_plist.c \
-        freebsd_database_directorydb.c \
-        freebsd_repository_ftp.c \
-        util.c \
-        exec.c \
-        file.c \
-        depend.c
+	database.c \
+	freebsd_plist.c \
+	freebsd_database_directorydb.c \
+	util.c \
+	file.c \
+	depend.c
 
 
 CFLAGS+=  -std=c99

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/base.h#3 (text+ko) ====


==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.c#7 (text+ko) ====

@@ -10,9 +10,9 @@
 #include <sys/tree.h>
 #include <sys/types.h>
 
+#include "pkg.h"
+#include "pkg_internal.h"
 #include "database.h"
-/* Cool kids club. */
-#include "internal.h"
 
 #include "util.h"
 
@@ -24,49 +24,49 @@
  * Verify the magic value in a package database.  If there is a mismatch, crash
  * the client application.
  */
-void
+static void
 _pkg_db_check_magic(struct pkg_db *db, const char *func)
 {
-        if (db->magic != MAGIC) {
-                PKG_CLIENT_CRASH(func, "database magic number mismatch.");
-        }
+	if (db->magic != MAGIC) {
+		PKG_CLIENT_CRASH(func, "database magic number mismatch.");
+	}
 }
 
 struct pkg_db *
 pkg_db_create(void)
 {
-        struct pkg_db *db;
+	struct pkg_db *db;
 
-        db = calloc(1, sizeof(*db));
-        if (db == NULL) {
-                return (NULL);
-        }
+	db = calloc(1, sizeof(*db));
+	if (db == NULL) {
+		return (NULL);
+	}
 
-        db->magic = MAGIC;
-        /* If NULL, closed.  If not NULL, open. */
-        db->internal = NULL;
+	db->magic = MAGIC;
+	/* If NULL, closed.  If not NULL, open. */
+	db->internal = NULL;
 
-        /* TODO: NULL out callback pointers. */
-        db->open = fbsd_directorydb_open;
-        db->all = fbsd_directorydb_all;
-        db->get = fbsd_directorydb_get;
+	/* TODO: NULL out callback pointers. */
+	db->open = fbsd_directorydb_open;
+	db->all = fbsd_directorydb_all;
+	db->get = fbsd_directorydb_get;
 
-        return (db);
+	return (db);
 }
 
 int
 pkg_db_finish(struct pkg_db *db)
 {
-        if (db->internal != NULL) {
-                if (pkg_db_close(db) != PKG_OK) {
-                        warnx("Could not close pkg_db (%s)\n", db->path);
-                        return (PKG_NOT_OK);
-                }
-        }
+	if (db->internal != NULL) {
+		if (pkg_db_close(db) != PKG_OK) {
+			warnx("Could not close pkg_db (%s)\n", db->path);
+			return (PKG_NOT_OK);
+		}
+	}
 
-        free(db);
+	free(db);
 
-        return (PKG_OK);
+	return (PKG_OK);
 }
 
 /*
@@ -75,127 +75,101 @@
 int
 pkg_db_open(struct pkg_db *db, const char *path)
 {
-        int r;
+	int r;
 
-        _pkg_db_check_magic(db, __func__);
-        
-        r = PKG_NOT_OK;
-        if ((r = db->open(db, path)) == PKG_OK) {
-                strcpy(db->path, path);
+	_pkg_db_check_magic(db, __func__);
+	
+	r = PKG_NOT_OK;
+	if ((r = db->open(db, path)) == PKG_OK) {
+		strcpy(db->path, path);
 	}
 
-        return (r);
+	return (r);
 }
 
 struct pkg_list *
-pkg_db_all(struct pkg_db *db)
+pkg_db_pkgs(struct pkg_db *db)
 {
-        return (db->all(db));
+	return (db->all(db));
 }
 
+#if 0
 uid_t
 pkg_db_owner(struct pkg_db *db)
 {
-        if (db->internal == NULL) {
-                return (PKG_NOT_OK);
-        }
-        return (db->owner(db));
+	if (db->internal == NULL) {
+		return (PKG_NOT_OK);
+	}
+	return (db->owner(db));
 }
 
 const char *
 pkg_db_path(struct pkg_db *db)
 {
-        if (db->internal == NULL) {
-                return (NULL);
-        }
+	if (db->internal == NULL) {
+		return (NULL);
+	}
 
-        return (db->path);
+	return (db->path);
 }
+#endif
 
 int
 pkg_db_close(struct pkg_db *db)
 {
-        int r;
+	int r;
 
-        if (db->internal != NULL) {
-                if (db->close) {
-                        r = db->close(db);
-                } else {
-                        r = PKG_OK;
-                }
-        } else {
-                /* kaboom? */
-                return (PKG_NOT_OK);
-        }
+	if (db->internal != NULL) {
+		if (db->close) {
+			r = db->close(db);
+		} else {
+			r = PKG_OK;
+		}
+	} else {
+		/* kaboom? */
+		return (PKG_NOT_OK);
+	}
 
-        return (r);
+	return (r);
 }
 
 struct pkg *
 pkg_db_add(struct pkg_db *db, const char *name, const char *origin, 
-        const char *comment, const char *description)
+	const char *comment, const char *description)
 {
-        struct pkg *pkg;
-        
-        pkg = pkg_alloc();
-        if (pkg == NULL) {
-                return (NULL);
-        }
+	struct pkg *pkg;
+	
+	pkg = pkg_alloc();
+	if (pkg == NULL) {
+		return (NULL);
+	}
 
-        /* Do the add and set up pkg. */
-        if (db->add(db, pkg, name, origin, comment, description) != PKG_OK) {
-                pkg_release(pkg);
-                return (NULL);
-        }
+	/* Do the add and set up pkg. */
+	if (db->add(db, pkg, name, origin, comment, description) != PKG_OK) {
+		pkg_release(pkg);
+		return (NULL);
+	}
 
-        return (pkg);
+	return (pkg);
 }
 
 struct pkg *
 pkg_db_get(struct pkg_db *db, const char *key)
 {
-        /* XXX: This function is a perfect example of why I need error
-         * properties. */
-        struct pkg *pkg;
-        
-        pkg = pkg_alloc();
-        if (pkg == NULL) {
-                return (NULL);
-        }
+	/* XXX: This function is a perfect example of why I need error
+	 * properties. */
+	struct pkg *pkg;
+	
+	pkg = pkg_alloc();
+	if (pkg == NULL) {
+		return (NULL);
+	}
 
-        strcpy(pkg->key, key);
-        if (db->get(db, pkg, key) != PKG_OK) {
-                return (NULL);
-        }
+	strcpy(pkg->key, key);
+	if (db->get(db, pkg, key) != PKG_OK) {
+		return (NULL);
+	}
 
-        return (pkg);
-}
-
-int
-pkg_db_delete(struct pkg_db *db, const char *key)
-{
-        /* Does a complete removal of all information pertaining to pkg key from
-         * the database.  Any pkg objects for this package or now invalid/stale.
-         * */
-        return (db->delete(db, key));
-}
-
-int
-pkg_db_destroy(struct pkg_db *db, struct pkg *p)
-{
-        (void)db;
-        (void)p;
-        return (PKG_OK);
-}
-
-int
-pkg_db_revert(struct pkg_db *db)
-{
-        return (db->revert(db));
+	return (pkg);
 }
 
-int
-pkg_db_sync(struct pkg_db *db)
-{
-        return (db->sync(db));
-}

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/database.h#6 (text+ko) ====

@@ -6,64 +6,84 @@
 #ifndef __LIBPKG_DATABASE_H__
 #define __LIBPKG_DATABASE_H__
 
+#include <limits.h>
 #include <sys/types.h>
 
 #include "pkg.h"
 
-/* Allocate a new pkg_db object. */
-struct pkg_db           *pkg_db_create(void);
+struct pkg_db {
+	unsigned int magic; /* init */
+	char path[PATH_MAX];
+	/* Internal db pointer for whatever backend is in use. */
+	void *internal;
+
+	int		      (*add) (struct pkg_db *, struct pkg *,
+				const char *, const char *, const char *,
+				const char *);
+	int		      (*close) (struct pkg_db *);
+	int		      (*contains) (struct pkg_db *, const char *);
+	int		      (*get) (struct pkg_db *, struct pkg *,
+				const char *);
+	struct pkg_list	 *(*all) (struct pkg_db *);
+	int (*open) (struct pkg_db *, const char *);
+	uid_t (*owner) (struct pkg_db *);
+	int (*delete) (struct pkg_db *, const char *);
+	int (*revert) (struct pkg_db *);
+	int (*sync) (struct pkg_db *);
+};
 
+#if 0
 /* Free a pkg_db object.  Closes with no sync if open. */
-int                      pkg_db_finish(struct pkg_db *);
+int		      pkg_db_finish(struct pkg_db *);
 
 /* Get the path of a pkg_db . */
-const char              *pkg_db_path(struct pkg_db *);
+const char	      *pkg_db_path(struct pkg_db *);
 
-struct pkg_list         *pkg_db_all(struct pkg_db *);
+struct pkg_list	 *pkg_db_all(struct pkg_db *);
 
 /* XXX: Get allocates a package if the package is already in the db.  Add
  * allocates a package if the package is NOT already in the db. */
 
 /* Create a pkg in a pkg_db.  If the pkg already exists, returns NULL. */
-struct pkg              *pkg_db_add(struct pkg_db *, const char *, const char *,
-                        const char *, const char *);
+struct pkg	      *pkg_db_add(struct pkg_db *, const char *, const char *,
+			const char *, const char *);
 
 /* Get a pkg from a pkg_db.  If the package does not exist, returns NULL. */
-struct pkg              *pkg_db_get(struct pkg_db *, const char *);
+struct pkg	      *pkg_db_get(struct pkg_db *, const char *);
 
 // /* Get all pkgs from a pkg_db that match an expressions. */
-// struct pkg_list         *pkg_db_get(struct pkg_db *, const char *);
+// struct pkg_list	 *pkg_db_get(struct pkg_db *, const char *);
 
 /* Deletes a pkg from a pkg_db. */
-int                      pkg_db_delete(struct pkg_db *, const char *);
+int		      pkg_db_delete(struct pkg_db *, const char *);
 
 /* Destroy a pkg object that was created by pkg_db. */
-int                      pkg_db_destroy(struct pkg_db *, struct pkg *);
+int		      pkg_db_destroy(struct pkg_db *, struct pkg *);
 
 /* Returns the uid of the owner of a pkg_db. */
-uid_t                    pkg_db_owner(struct pkg_db *);
+uid_t		    pkg_db_owner(struct pkg_db *);
 
-void                     pkg_db_set_callbacks(struct pkg_db *, 
-                                int (*close) (struct pkg_db *),
-                                struct pkg *(*add) (struct pkg_db *, const char *),
-                                int (*delete) (struct pkg_db *, const char *),
-                                int (*open) (struct pkg_db *, const char *),
-                                uid_t (*owner) (struct pkg_db *),
-                                struct pkg *(*get) (struct pkg_db *, const char *,
-                                        uint32_t),
-                                int (*revert) (struct pkg_db *),
-                                int (*sync) (struct pkg_db *));
+void		     pkg_db_set_callbacks(struct pkg_db *, 
+				int (*close) (struct pkg_db *),
+				struct pkg *(*add) (struct pkg_db *, const char *),
+				int (*delete) (struct pkg_db *, const char *),
+				int (*open) (struct pkg_db *, const char *),
+				uid_t (*owner) (struct pkg_db *),
+				struct pkg *(*get) (struct pkg_db *, const char *,
+					uint32_t),
+				int (*revert) (struct pkg_db *),
+				int (*sync) (struct pkg_db *));
 
 /* Undo all changes to a pkg_db. */
-int                      pkg_db_revert(struct pkg_db *);
+int		      pkg_db_revert(struct pkg_db *);
 
 /* Open a database for interaction. */
-int                      pkg_db_open(struct pkg_db *, const char *);
+int		      pkg_db_open(struct pkg_db *, const char *);
 
 /* Close a database. */
-int                      pkg_db_close(struct pkg_db *);
+int		      pkg_db_close(struct pkg_db *);
 
 /* Sync changes to a pkg_db to disk. */
-int                      pkg_db_sync(struct pkg_db *);
-
+int		      pkg_db_sync(struct pkg_db *);
+#endif
 #endif

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/database_internal.h#5 (text+ko) ====

@@ -10,24 +10,24 @@
 
 /* Define the package database type. */
 struct pkg_db {
-        unsigned int magic; /* init */
-        char path[PATH_MAX];
-        /* Internal db pointer for whatever backend is in use. */
-        void *internal;
+	unsigned int magic; /* init */
+	char path[PATH_MAX];
+	/* Internal db pointer for whatever backend is in use. */
+	void *internal;
 
-        int                      (*add) (struct pkg_db *, struct pkg *,
-                                const char *, const char *, const char *,
-                                const char *);
-        int                      (*close) (struct pkg_db *);
-        int                      (*contains) (struct pkg_db *, const char *);
-        int                      (*get) (struct pkg_db *, struct pkg *,
-                                const char *);
-        struct pkg_list         *(*all) (struct pkg_db *);
-        int (*open) (struct pkg_db *, const char *);
-        uid_t (*owner) (struct pkg_db *);
-        int (*delete) (struct pkg_db *, const char *);
-        int (*revert) (struct pkg_db *);
-        int (*sync) (struct pkg_db *);
+	int		      (*add) (struct pkg_db *, struct pkg *,
+				const char *, const char *, const char *,
+				const char *);
+	int		      (*close) (struct pkg_db *);
+	int		      (*contains) (struct pkg_db *, const char *);
+	int		      (*get) (struct pkg_db *, struct pkg *,
+				const char *);
+	struct pkg_list	 *(*all) (struct pkg_db *);
+	int (*open) (struct pkg_db *, const char *);
+	uid_t (*owner) (struct pkg_db *);
+	int (*delete) (struct pkg_db *, const char *);
+	int (*revert) (struct pkg_db *);
+	int (*sync) (struct pkg_db *);
 };
 
 /* Check the magic value in a database. */

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/depend.c#3 (text+ko) ====

@@ -2,40 +2,41 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "pkg.h"
 #include "depend.h"
 
 struct pkg_depend *
 pkg_depend_alloc(void)
 {
-        return (calloc(1, sizeof(struct pkg_depend)));
+	return (calloc(1, sizeof(struct pkg_depend)));
 }
 
 const char *
 pkg_depend_name(struct pkg_depend *dep)
 {
-        return (dep->name);
+	return (dep->name);
 }
 
 const char *
 pkg_depend_origin(struct pkg_depend *dep)
 {
-        return (dep->origin);
+	return (dep->origin);
 }
 
 const char *
 pkg_depend_version(struct pkg_depend *dep)
 {
-        return (dep->name);
+	return (dep->name);
 }
 
 void
 _pkg_depend_set_name(struct pkg_depend *dep, const char *name)
 {
-        strncpy(dep->name, name, PATH_MAX);
+	strncpy(dep->name, name, PATH_MAX);
 }
 
 void
 _pkg_depend_set_origin(struct pkg_depend *dep, const char *origin)
 {
-        strncpy(dep->origin, origin, PATH_MAX);
+	strncpy(dep->origin, origin, PATH_MAX);
 }

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/depend.h#3 (text+ko) ====

@@ -1,27 +1,32 @@
 #ifndef __LIBPKG_DEPEND_H__
 #define __LIBPKG_DEPEND_H__
 
+#if 0
 #include <limits.h>
 #include <sys/queue.h>
 
 struct pkg_depend {
-        char name[PATH_MAX];
-        char version[256];
-        char origin[PATH_MAX];
+	char name[PATH_MAX];
+	char version[256];
+	char origin[PATH_MAX];
 
-        TAILQ_ENTRY(pkg_depend) next;
+	TAILQ_ENTRY(pkg_depend) next;
 };
 
 TAILQ_HEAD(pkg_depend_list, pkg_depend);
+#endif
 
-struct pkg_depend               *pkg_depend_alloc(void);
-const char                      *pkg_depend_name(struct pkg_depend *);
-const char                      *pkg_depend_origin(struct pkg_depend *);
-const char                      *pkg_depend_version(struct pkg_depend *);
+#include "pkg_types.h"
 
-void                             _pkg_depend_set_name(struct pkg_depend *,
-                                const char *);
-void                             _pkg_depend_set_origin(struct pkg_depend *,
-                                const char *);
+struct pkg_depend	       *pkg_depend_alloc(void);
+#if 0
+const char		      *pkg_depend_name(struct pkg_depend *);
+const char		      *pkg_depend_origin(struct pkg_depend *);
+const char		      *pkg_depend_version(struct pkg_depend *);
+#endif
+void			     _pkg_depend_set_name(struct pkg_depend *,
+				const char *);
+void			     _pkg_depend_set_origin(struct pkg_depend *,
+				const char *);
 
 #endif

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.c#3 (text+ko) ====

@@ -8,7 +8,7 @@
 char * 
 pkg_exec_run(const char *fmt, char *arg)
 {
-        (void)fmt;
-        (void)arg;
-        return (NULL);
+	(void)fmt;
+	(void)arg;
+	return (NULL);
 }

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec.h#3 (text+ko) ====


==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/exec_internal.h#3 (text+ko) ====


==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/file.c#5 (text+ko) ====

@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "pkg.h"
 #include "file.h"
 #include "util.h"
 
@@ -10,78 +11,80 @@
 struct pkg_file *
 pkg_file_alloc(void)
 {
-        return (calloc(1, sizeof(struct pkg_file)));
+	return (calloc(1, sizeof(struct pkg_file)));
 }
 
 void
 pkg_file_release(struct pkg_file *file)
 {
-        free(file);
+	free(file);
 }
 
 const char *
 pkg_file_prefix(struct pkg_file *file)
 {
-        return (file->prefix);
+	return (file->prefix);
 }
 
 void
 _pkg_file_set_prefix(struct pkg_file *file, const char *prefix)
 {
-        strncpy(file->prefix, prefix, PATH_MAX);
+	strncpy(file->prefix, prefix, PATH_MAX);
 }
 
 const char *
 pkg_file_pathname(struct pkg_file *file)
 {
-        return (file->pathname);
+	return (file->pathname);
 }
 
 void
 _pkg_file_set_pathname(struct pkg_file *file, const char *pathname)
 {
-        strncpy(file->pathname, pathname, PATH_MAX);
+	strncpy(file->pathname, pathname, PATH_MAX);
 }
 
 int
 pkg_file_ignore(struct pkg_file *file)
 {
-        return (file->ignore);
+	return (file->ignore);
 }
 
 void
 _pkg_file_set_ignore(struct pkg_file *file)
 {
-        file->ignore = 1;
+	file->ignore = 1;
 }
 
 const char *
 pkg_file_hash(struct pkg_file *file)
 {
-        return (file->hash);
+	return (file->hash);
 }
 
+#if 0
 const char *
 pkg_file_update_hash(struct pkg_file *file)
 {
-        return (file->update_hash(file));
+	return (file->update_hash(file));
 }
+#endif
 
 void
 _pkg_file_set_hash(struct pkg_file *file, const char *hash)
 {
-        strncpy(file->hash, hash, 33);
+	strncpy(file->hash, hash, 33);
 }
 
 const struct stat *
 pkg_file_stat(struct pkg_file *file)
 {
-        char final[PATH_MAX];
+	char final[PATH_MAX];
 
-        _pkg_util_path_join(final, file->prefix, file->pathname);
-        
-        /* there's no stat_r, are we thread safe? */
-        if (stat(final, &file->sb) < 0) return (NULL);
+	_pkg_util_path_join(final, file->prefix, file->pathname);
+	
+	/* there's no stat_r, are we thread safe? */
+	if (stat(final, &file->sb) < 0) return (NULL);
 
-        return ((const struct stat *)&file->sb);
+	return ((const struct stat *)&file->sb);
 }

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/file.h#5 (text+ko) ====

@@ -1,51 +1,57 @@
 #ifndef __LIBPKG_FILE_H__
 #define __LIBPKG_FILE_H__
 
+#if 0
 #include <limits.h>
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 
 struct pkg_file {
-        /* Give each file in a package a unique id.  Prefix and pathname aren't
-         * reliable keys. */
-        unsigned int     id;
-        struct stat      sb;
-        
-        /* The package that this file is in. */
-        struct pkg      *pkg;
+	/* Give each file in a package a unique id.  Prefix and pathname aren't
+	 * reliable keys. */
+	unsigned int     id;
+	struct stat      sb;
+	
+	/* The package that this file is in. */
+	struct pkg      *pkg;
 
-        char             prefix[PATH_MAX];
-        char             pathname[PATH_MAX];
-        int              ignore;
+	char	     prefix[PATH_MAX];
+	char	     pathname[PATH_MAX];
+	int	      ignore;
 
-        char             hash[33];
+	char	     hash[33];
 
-        const char      *(*update_hash) (struct pkg_file *);
+	const char      *(*update_hash) (struct pkg_file *);
 
-        TAILQ_ENTRY(pkg_file) next;
+	TAILQ_ENTRY(pkg_file) next;
 };
 
 TAILQ_HEAD(pkg_file_list, pkg_file);
+#endif
 
-struct pkg_file         *pkg_file_alloc(void);
-void                     pkg_file_release(struct pkg_file *);
+#include "pkg_types.h"
+
+struct pkg_file		*pkg_file_alloc(void);
+void			 pkg_file_release(struct pkg_file *);
 
-const char              *pkg_file_prefix(struct pkg_file *);
-const char              *pkg_file_pathname(struct pkg_file *);
-int                      pkg_file_ignore(struct pkg_file *);
-const char              *pkg_file_hash(struct pkg_file *);
-const char              *pkg_file_update_hash(struct pkg_file *);
+#if 0
+const char	      *pkg_file_prefix(struct pkg_file *);
+const char	      *pkg_file_pathname(struct pkg_file *);
+int		      pkg_file_ignore(struct pkg_file *);
+const char	      *pkg_file_hash(struct pkg_file *);
+const char	      *pkg_file_update_hash(struct pkg_file *);
 
 const struct stat       *pkg_file_stat(struct pkg_file *);
+#endif
 
 /* These only set the fields in the immediate object, they don't touch the db.
  * */
 
-void                     _pkg_file_set_prefix(struct pkg_file *, const char *);
-void                     _pkg_file_set_pathname(struct pkg_file *,
-                        const char *);
-void                     _pkg_file_set_ignore(struct pkg_file *);
-void                     _pkg_file_set_hash(struct pkg_file *, const char *);
+void		     _pkg_file_set_prefix(struct pkg_file *, const char *);
+void		     _pkg_file_set_pathname(struct pkg_file *,
+			const char *);
+void		     _pkg_file_set_ignore(struct pkg_file *);
+void		     _pkg_file_set_hash(struct pkg_file *, const char *);
 
 #endif

==== //depot/projects/soc2010/dforsyth_libpkg/libpkg/freebsd_database_directorydb.c#6 (text+ko) ====

@@ -13,9 +13,11 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <limits.h>
+#include <unistd.h>
+
+#include "pkg.h"
 
-/* Cool kids club. */
-#include "internal.h"
+#include "database.h"
 #include "freebsd_database_directorydb.h"
 
 #include "freebsd_plist.h"
@@ -23,64 +25,72 @@
 #include "file.h"
 #include "depend.h"
 
+#include "util.h"
+
+/* XXX(dforsyth): Get this out of here as soon as a better pkg creation and
+ * setup method is in place. */
+#include "pkg_internal.h"
+
 struct _read_plist {
-        struct pkg_property *plist;
-        char key[PATH_MAX];
-        uint32_t parsed;
-        RB_ENTRY(_read_plist) entry;
+	struct pkg_property *plist;
+	char key[PATH_MAX];
+	uint32_t parsed;
+	RB_ENTRY(_read_plist) entry;
 };
 
 struct _directorydb {
-        /* Location of the database. */
-        char path[PATH_MAX];
-        
-        /* Journal handle. */
-        int journal;
-        char journal_path[PATH_MAX];
-        char journal_dir_path[PATH_MAX];
+	/* Location of the database. */
+	char path[PATH_MAX];
+	
+	/* Journal handle. */
+	int journal;
+	char journal_path[PATH_MAX];
+	char journal_dir_path[PATH_MAX];
 
-        /* A NULL terminated list of keys the db currently has. */
-        char **keylist;
+	/* A NULL terminated list of keys the db currently has. */
+	char **keylist;
 
-        /* 
-         * The time of our last access.  If this has changed, another
-         * directorydb instance has changes something, so we need to refresh.
-         */
-        time_t last;
+	/* 
+	 * The time of our last access.  If this has changed, another
+	 * directorydb instance has changes something, so we need to refresh.
+	 */
+	time_t last;
 
-        RB_HEAD(plist_head, _read_plist) plist_head;
+	RB_HEAD(plist_head, _read_plist) plist_head;
 };
 
-#define CONTENTS        0x00000001
+#define CONTENTS	0x00000001
 #define DESCRIPTION     0x00000002
-#define COMMENT         0x00000004
-#define DISPLAY         0x00000008
+#define COMMENT	 0x00000004
+#define DISPLAY	 0x00000008
 
 static struct pkg_info {
-        uint32_t info_mask;
-        const char *info_name;
-        const char *file_name;
+	uint32_t info_mask;
+	const char *info_name;
+	const char *file_name;
 } pkg_entries [] = {
-        { CONTENTS, FBSD_METANAME_CONTENTS, "+CONTENTS" },
-        { DESCRIPTION, FBSD_METANAME_DESCRIPTION, "+DESC" },
-        { COMMENT, FBSD_METANAME_COMMENT, "+COMMENT" },
-        { DISPLAY, FBSD_METANAME_DISPLAY, "+DISPLAY" },
-        { 0, NULL, NULL },
+	{ CONTENTS, FBSD_METANAME_CONTENTS, "+CONTENTS" },
+	{ DESCRIPTION, FBSD_METANAME_DESCRIPTION, "+DESC" },
+	{ COMMENT, FBSD_METANAME_COMMENT, "+COMMENT" },
+	{ DISPLAY, FBSD_METANAME_DISPLAY, "+DISPLAY" },
+	{ 0, NULL, NULL },
 };
 
-static int                       fbsd_directorydb_read_pkg(
-                                struct _directorydb *, struct pkg *);
-static char                     *read_file(const char *);
-static int                       _read_plist_cmp(struct _read_plist *,
-                                struct _read_plist *);
-static int                       dselect(const struct dirent *);
-static void                      fbsd_directorydb_pkg_setup(struct pkg_db *, 
-                                struct pkg *, const char *);
+static int		       fbsd_directorydb_read_pkg(
+				struct _directorydb *, struct pkg *);
+int			      fbsd_directorydb_finish(struct pkg_db *,
+				struct pkg *);
+static char		     *read_file(const char *);
+static int		       _read_plist_cmp(struct _read_plist *,
+				struct _read_plist *);
+static int		       dselect(const struct dirent *);
+static void		      fbsd_directorydb_pkg_setup(struct pkg_db *, 
+				struct pkg *, const char *);
 
 RB_GENERATE_STATIC(plist_head, _read_plist, entry, _read_plist_cmp);
 
-#define PKG_DIRDB_MAGIC         0x11111111
-#define DB_DIRDB_MAGIC          0x11111111
+#define PKG_DIRDB_MAGIC	 0x11111111
+#define DB_DIRDB_MAGIC	  0x11111111
 
 /* The journal file. */
 #define JOURNAL ".journal"
@@ -95,282 +105,293 @@
 static int
 _read_plist_cmp(struct _read_plist *a, struct _read_plist *b)
 {
-        return (strcmp(a->key, b->key));
+	return (strcmp(a->key, b->key));
 }
 
 static int
 dselect(const struct dirent *ent)
 {
-        return (ent->d_name[0] != '.' && ent->d_type == DT_DIR);
+	return (ent->d_name[0] != '.' && ent->d_type == DT_DIR);
 }
 
 /* Close a "connection" to a directorydb. */
 int
 fbsd_directorydb_close(struct pkg_db *db)
 {
-        struct _directorydb *d = db->internal;
-        close(d->journal);
-        return (0);
+	struct _directorydb *d = db->internal;
+	close(d->journal);
+	return (0);
 }
 
 /* Open a "connection" to a directorydb. */
 int
 fbsd_directorydb_open(struct pkg_db *db, const char *path)
 {
-        struct _directorydb *d;
-        struct stat sb;
-        int jfd;

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


More information about the p4-projects mailing list