Date: Sat, 27 Jun 2009 05:16:53 GMT From: David Forsythe <dforsyth@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 165300 for review Message-ID: <200906270516.n5R5GrdH061033@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=165300 Change 165300 by dforsyth@squirrel on 2009/06/27 05:16:29 Building pkg_sub. Build with errors, mock pkg_info does nothing because iteration functions aren't built. Affected files ... .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/Makefile#9 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#27 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#26 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.h#17 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_sub.c#2 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_sub.h#2 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.c#18 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.h#12 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb.c#9 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb.h#5 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb_pkgdb_sub.c#10 delete .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb_pkgdb_sub.h#6 delete .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_old.c#2 delete .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_old.h#3 delete .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_private.h#3 edit .. //depot/projects/soc2009/dforsyth_libpkg/old/pkgdb_hierdb_pkgdb_sub.c#1 add .. //depot/projects/soc2009/dforsyth_libpkg/old/pkgdb_hierdb_pkgdb_sub.h#1 add .. //depot/projects/soc2009/dforsyth_libpkg/old/pkgdb_old.c#1 add .. //depot/projects/soc2009/dforsyth_libpkg/old/pkgdb_old.h#1 add .. //depot/projects/soc2009/dforsyth_libpkg/tests/test.h#1 add Differences ... ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/Makefile#9 (text+ko) ==== @@ -1,8 +1,8 @@ LIB= pkg INCS= pkg.h WARNS= 6 -SRCS= pkgdb.c pkgdb_hierdb.c pkgdb_hierdb_pkgdb_sub.c pkg.c pkg_util.c \ - pkg_file.c pkg_dep.c pkg_cfl.c pkg_plist.c +SRCS= pkgdb.c pkgdb_hierdb.c pkg.c pkg_util.c pkg_file.c \ + pkg_dep.c pkg_cfl.c pkg_plist.c pkg_sub.c NO_MAN= yes .include <bsd.lib.mk> ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#27 (text+ko) ==== @@ -9,7 +9,6 @@ #include "pkg_file.h" #include "pkg_cfl.h" #include "pkg_plist.h" -#include "pkgdb_hierdb_pkgdb_sub.h" #include "pkgdb_hierdb.h" #include "pkgdb.h" #include "pkg_private.h" ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#26 (text+ko) ==== @@ -25,6 +25,7 @@ #define DB_NOT_OPEN 0x40000000 #define DB_OPEN 0x80000000 #define DB_NO_PKG 0x01000000 +#define DB_MEMORY_ERR 0x02000000 /* These should probably go to _private */ #define SUB_OK 0x00000000 @@ -36,6 +37,7 @@ #define SUB_NO_REQUIRED_BY 0x02000000 #define SUB_NO_FILE 0x04000000 #define SUB_EMPTY_FILE 0x08000000 +#define SUB_MEMORY_ERR 0x00100000 /* PKG Errors. */ ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.h#17 (text+ko) ==== @@ -1,6 +1,8 @@ #ifndef __PKG_PLIST_H__ #define __PKG_PLIST_H__ +#include <sys/queue.h> + /* Make these visible to the client. */ enum plist_elem { ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_sub.c#2 (text+ko) ==== @@ -3,57 +3,68 @@ #include <string.h> #include <sys/types.h> -#include <sys/stats.h> +#include <sys/stat.h> #include <fcntl.h> #include <unistd.h> +#include "pkg_private.h" +#include "pkg_util.h" #include "pkg_plist.h" #include "pkg.h" #include "pkg_sub.h" -struct pkg_sub { - /* directory name, path. */ - char *ident; - char *path; - - /* parsed plist. */ - struct pkg_plist *pl; - - /* relevant text. */ - char *comment_text; - char *contents_text; - char *desc_text; - char *display_text; - char *mtree_dirs_text; - char *required_by_text; - - /* status and error. */ - short dirty; - int error; -} - int pkg_sub_mark_dirty(struct pkg_sub *ps) { - if (!VALID_PKG_SUB(ps)) + if (ps == NULL) arg_rage_quit(__func__, "Not a valid package directory.", RAGE_AT_LIBPKG); - dir->dirty = 1; + ps->dirty = 1; return (PKG_SUB_OK); } int pkg_sub_mark_clean(struct pkg_sub *ps) { - if (!VALID_PKG_SUB(ps)) + if (ps == NULL) arg_rage_quit(__func__, "Not a valid package directory.", RAGE_AT_LIBPKG); - dir->dirty = 0; + ps->dirty = 0; return (PKG_SUB_OK); } +const char * +pkg_sub_file_id(enum pkg_sub_file_ident id) +{ + const char *ret; + switch (id) { + case (COMMENT_FILE_ID): + ret = COMMENT_FILE; + break; + case (CONTENTS_FILE_ID): + ret = CONTENTS_FILE; + break; + case (DESC_FILE_ID): + ret = DESC_FILE; + break; + case (DISPLAY_FILE_ID): + ret = DISPLAY_FILE; + break; + case (MTREE_DIRS_FILE_ID): + ret = MTREE_DIRS_FILE; + break; + case (REQUIRED_BY_FILE_ID): + ret = REQUIRED_BY_FILE; + break; + default: + ret = NULL; + } + + return (ret); +} + int pkg_sub_read_file_to_text(struct pkg_sub *ps, enum pkg_sub_file_ident id) { @@ -62,9 +73,11 @@ char *path; char *text; const char *filename; - struct stat db; + struct stat sb; - filename = pkg_sub_id(id); + filename = pkg_sub_file_id(id); + if (filename == NULL) + return (PKG_SUB_NOT_OK); path = path_build(ps->path, filename); s = lstat(path, &sb); if (s < 0 || !S_ISREG(sb.st_mode)) { @@ -72,14 +85,14 @@ return (PKG_SUB_NOT_OK | PKG_SUB_NO_FILE); } if (sb.st_size == 0) { - free(path) + free(path); return (PKG_SUB_NOT_OK | PKG_SUB_EMPTY_FILE); } fd = open(path, O_RDONLY); free(path); if (fd < 0) - return (PKG_SUB_NOT_OK | PKG_SUB_COULD_NOT_OPEN); + return (PKG_SUB_NOT_OK | PKG_SUB_COULD_NOT_OPEN_FILE); text = malloc(sb.st_size + 1); if (text == NULL) { @@ -113,7 +126,7 @@ case REQUIRED_BY_FILE_ID: ps->required_by_text = text; break; - default + default: free(text); return (PKG_SUB_NO_FILE); } @@ -121,37 +134,66 @@ return (PKG_SUB_OK); } + +/* Read all files into memory at once. */ + +int +pkg_sub_read_files(struct pkg_sub *ps) +{ + int status; + if (ps == NULL) + arg_rage_quit(__func__, "Not a valid pkg_sub.", RAGE_AT_LIBPKG); + + status = PKG_SUB_OK; + status |= pkg_sub_read_file_to_text(ps, COMMENT_FILE_ID); + status |= pkg_sub_read_file_to_text(ps, CONTENTS_FILE_ID); + status |= pkg_sub_read_file_to_text(ps, DESC_FILE_ID); + status |= pkg_sub_read_file_to_text(ps, DISPLAY_FILE_ID); + status |= pkg_sub_read_file_to_text(ps, MTREE_DIRS_FILE_ID); + status |= pkg_sub_read_file_to_text(ps, REQUIRED_BY_FILE_ID); + + + return (status); +} + +int +pkg_sub_reset(struct pkg_sub *ps) +{ + if (ps) ;; + return (PKG_SUB_OK); +} + /* Initialize a pkg_sub in a pkgdb. */ + int -pkg_sub_init(struct pkgdb *db, struct pkg_sub *ps, const char *ident) +pkg_sub_init(struct pkg_sub *ps, struct pkgdb *db, const char *ident) { - char *identp; char *pathp; - if (!VALID_PKGDB(db) || !VALID_PKG_SUB(ps) || ident == NULL) + if (db == NULL || ps == NULL || ident == NULL) arg_rage_quit(__func__, "", RAGE_AT_LIBPKG); - identp = strdup(ident); + pkg_sub_reset(ps); + pkg_sub_set_ident(ps, ident); pathp = path_build(pkgdb_db_root(db), ident); - if (identp == NULL || pathp == NULL) { - free(identp); + if (pathp == NULL) { free(pathp); return (PKG_SUB_NOT_OK | PKG_SUB_MEMORY_ERR); } - ps->ident = identp; ps->path = pathp; - + +/* pkg_plist_delete(ps->pl); ps->pl = NULL; - +*/ free(ps->comment_text); free(ps->contents_text); free(ps->desc_text); free(ps->display_text); - free(ps->mtree_text); - free(ps->required_text); + free(ps->mtree_dirs_text); + free(ps->required_by_text); ps->comment_text = NULL; ps->contents_text = NULL; ps->desc_text = NULL; @@ -165,12 +207,15 @@ return (PKG_SUB_OK); } +int +pkg_sub_set_ident(struct pkg_sub *ps, const char *ident) +{ + if (ps == NULL || ident == NULL) + return (PKG_SUB_NOT_OK); - return (OK); -} + ps->ident = strdup(ident); + if (ps->ident == NULL) + return (PKG_SUB_NOT_OK | PKG_SUB_MEMORY_ERR); -int -pkg_sub_set_plist(struct pkg_sub *ps, struct pkg_plist *pl) -{ - return (OK); + return (PKG_SUB_OK); } ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_sub.h#2 (text+ko) ==== @@ -1,10 +1,91 @@ #ifndef __PKG_DIR_H__ #define __PKG_DIR_H__ +#include "pkgdb.h" + +#define PKG_SUB_MEM_ERR(x) x & SUB_MEMORY_ERR + +#define PKG_SUB_OK 0x00000000 +#define PKG_SUB_NOT_OK 0x10000000 +#define PKG_SUB_MEMORY_ERR 0x20000000 +#define PKG_SUB_NO_FILE 0x40000000 +#define PKG_SUB_COULD_NOT_OPEN_FILE 0x80000000 +#define PKG_SUB_EMPTY_FILE 0x01000000 + +struct pkg_sub { + /* directory name, path. */ + char *ident; + char *path; + + /* parsed plist. */ + struct pkg_plist *pl; + + /* relevant text. */ + char *comment_text; + char *contents_text; + char *desc_text; + char *display_text; + char *mtree_dirs_text; + char *required_by_text; + + /* status and error. */ + short dirty; + int error; +}; + +enum pkg_sub_file_ident { + COMMENT_FILE_ID, + CONTENTS_FILE_ID, + DESC_FILE_ID, + DISPLAY_FILE_ID, + MTREE_DIRS_FILE_ID, + REQUIRED_BY_FILE_ID +}; + struct pkg_sub; int pkg_sub_mark_dirty(struct pkg_sub *ps); int pkg_sub_mark_clean(struct pkg_sub *ps); +int pkg_sub_init(struct pkg_sub *ps, struct pkgdb *db, const char *ident); + +int pkg_sub_reset(struct pkg_sub *ps); + +const char *pkg_sub_file_id(enum pkg_sub_file_ident id); + +int pkg_sub_read_file_to_text(struct pkg_sub *ps, + enum pkg_sub_file_ident id); + +int pkg_sub_read_files(struct pkg_sub *ps); + +const char *pkg_sub_ident(struct pkg_sub *ps); + +int pkg_sub_set_ident(struct pkg_sub *ps, const char *ident); + +const char *pkg_sub_contents(struct pkg_sub *ps); + +int pkg_sub_set_contents(struct pkg_sub *ps, const char *contents); + +const char *pkg_sub_comment(struct pkg_sub *ps); + +int pkg_sub_set_comment(struct pkg_sub *ps, const char *comment); + +const char *pkg_sub_desc(struct pkg_sub *ps); + +int pkg_sub_set_desc(struct pkg_sub *ps, const char *desc); + +const char *pkg_sub_display(struct pkg_sub *ps); + +int pkg_sub_set_display(struct pkg_sub *ps, const char *display); + +const char *pkg_sub_mtree_dirs(struct pkg_sub *ps); + +int pkg_sub_set_mtree_dirs(struct pkg_sub *ps, const char *mtree_dirs); + +const char *pkg_sub_required_by(struct pkg_sub *ps); + +int pkg_sub_set_required_by(struct pkg_sub *ps, const char *required_by); + + #endif ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.c#18 (text+ko) ==== @@ -4,7 +4,7 @@ #include <sys/queue.h> #include "pkg_util.h" -#include "pkgdb_hierdb_pkgdb_sub.h" +#include "pkg_sub.h" #include "pkgdb_hierdb.h" #include "pkgdb_private.h" #include "pkgdb.h" @@ -65,7 +65,7 @@ if (!db->open) return (DB_NOT_OPEN); - pkgdb_pkgdb_sub_list_free(db); /* Should set sub_count to 0. */ + pkgdb_pkg_sub_list_free(db); /* Should set sub_count to 0. */ free(db->db_root); db->open = 0; @@ -88,7 +88,7 @@ pkgdb_pkg_next(struct pkgdb *db, struct pkg *p) { int status; - struct pkgdb_sub *sub; + struct pkg_sub *ps; if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_CLIENT); @@ -100,123 +100,108 @@ * can have multiple copies of a package which do not share a state. * Is this a terrible idea? Stay tuned to find out. */ pkg_reset(p); - sub = pkgdb_pkgdb_sub_list_next(db); - if (sub == NULL) { + ps = pkgdb_pkg_sub_list_next(db); + if (ps == NULL) { return (DB_NO_PKG); /* Already at the end. */ } status = OK; - status |=pkg_set_ident(p, pkgdb_sub_ident(sub)); - /* Status should be pointless to check here, because the init loop - * doesn't bother with subdirectories that don't have a plist. */ - status |= pkg_set_contents(p, pkgdb_sub_contents(sub)); - status |= pkg_set_comment(p, pkgdb_sub_comment(sub)); - status |= pkg_set_description(p, pkgdb_sub_desc(sub)); - status |= pkg_set_display(p, pkgdb_sub_display(sub)); - status |= pkg_set_mtree_dirs(p, pkgdb_sub_mtree_dirs(sub)); - status |= pkg_set_required_by(p, pkgdb_sub_required_by(sub)); - /* I'm not sure all of these have to be loaded, but we can make a - * decision about that later. */ + - /* Error codes to the client. */ return (status); } -#if 0 int pkgdb_pkg_get(struct pkgdb *db, struct pkg *p, const char *ident) { /* TODO: Write this function. */ int status; + struct pkg_sub *ps; if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_CLIENT); if (p == NULL) arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); + if (ident == NULL) + arg_rage_quit(__func__, "Not a valid identifier.", + RAGE_AT_CLIENT); status = PKG_OK; pkg_reset(p); - - return (OK); + ps = pkgdb_pkg_sub_get(db, ident); + if (ps == NULL) + return (DB_NO_PKG); + status = pkg_sub_read_files(ps); + if (status == NOT_OK) { + /* might have to free some things in here. */ + return (NOT_OK); + } + + return (status); } -/* Grab a specific sub out of the pkgdb_sub list. */ -struct pkgdb_sub * -pkgdb_pkgdb_sub_get(struct pkgdb *db, const char *ident) +struct pkg_sub * +pkgdb_pkg_sub_get(struct pkgdb *db, const char *ident) { - /* TODO: Write this function. */ - return (NULL); + struct pkg_sub *ps; + + if (db || ident) + ;; + + ps = NULL; + + return (ps); } -#endif void -pkgdb_pkgdb_sub_list_free(struct pkgdb *db) -{ - struct pkgdb_sub *sub1; - struct pkgdb_sub *sub2; - - if (db == NULL) - arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_LIBPKG); - - pkgdb_pkgdb_sub_list_init(db); - sub1 = pkgdb_pkgdb_sub_list_first(db); - while (sub1 != NULL) { - sub2 = pkgdb_pkgdb_sub_list_next(db); - pkgdb_sub_reset(sub1); - sub1 = sub2; - } +pkgdb_pkg_sub_list_free(struct pkgdb *db) +{ + if (db) return; + return; } -struct pkgdb_sub * -pkgdb_pkgdb_sub_list_next(struct pkgdb *db) +struct pkg_sub * +pkgdb_pkg_sub_list_next(struct pkgdb *db) { - struct pkgdb_sub *sub; + struct pkg_sub *ps; if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_LIBPKG); - if (db->sub_curr == NULL) - sub = pkgdb_pkgdb_sub_list_first(db); - else - sub = TAILQ_NEXT(db->sub_curr, next); - - if (sub != NULL) - db->sub_curr = sub; - - return (sub); + ps = NULL; + return (ps); } -struct pkgdb_sub * -pkgdb_pkgdb_sub_list_first(struct pkgdb *db) +struct pkg_sub * +pkgdb_pkg_sub_list_first(struct pkgdb *db) { - struct pkgdb_sub *sub; + struct pkg_sub *ps; if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_LIBPKG); - - sub = TAILQ_FIRST(&db->sub_head); - return (sub); + + ps = db->ps_list + 0; + return (ps); } void -pkgdb_pkgdb_sub_list_append(struct pkgdb *db, struct pkgdb_sub *sub) +pkgdb_pkg_sub_list_append(struct pkgdb *db, struct pkg_sub *ps) { if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_LIBPKG); - if (sub == NULL) + if (ps == NULL) arg_rage_quit(__func__, "Not a valid sub directory.", RAGE_AT_LIBPKG); - - TAILQ_INSERT_TAIL(&db->sub_head, sub, next); + return; } void -pkgdb_pkgdb_sub_list_init(struct pkgdb *db) +pkgdb_pkg_sub_list_init(struct pkgdb *db) { if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_LIBPKG); - TAILQ_INIT(&db->sub_head); + db->ps_curr = NULL; } char * ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.h#12 (text+ko) ==== @@ -5,15 +5,18 @@ struct pkgdb; -void pkgdb_pkgdb_sub_list_free(struct pkgdb *db); +void pkgdb_pkg_sub_list_free(struct pkgdb *db); + +void pkgdb_pkg_sub_list_init(struct pkgdb *db); + +void pkgdb_pkg_sub_list_reset_iter(struct pkgdb *db); -void pkgdb_pkgdb_sub_list_init(struct pkgdb *db); +struct pkg_sub *pkgdb_pkg_sub_list_next(struct pkgdb *db); -struct pkgdb_sub *pkgdb_pkgdb_sub_list_next(struct pkgdb *db); +struct pkg_sub *pkgdb_pkg_sub_list_first(struct pkgdb *db); -struct pkgdb_sub *pkgdb_pkgdb_sub_list_first(struct pkgdb *db); +void pkgdb_pkg_sub_list_append(struct pkgdb *db, struct pkg_sub *sub); -void pkgdb_pkgdb_sub_list_append(struct pkgdb *db, struct pkgdb_sub *sub); +struct pkg_sub *pkgdb_pkg_sub_get(struct pkgdb *db, const char *ident); -struct pkgdb_sub *pkgdb_pkgdb_sub_get(struct pkgdb *db, const char *ident); #endif ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb.c#9 (text+ko) ==== @@ -12,7 +12,6 @@ #include "pkgdb.h" #include "pkgdb_private.h" #include "pkgdb_hierdb.h" -#include "pkgdb_hierdb_pkgdb_sub.h" #include "pkg_sub.h" int @@ -43,9 +42,8 @@ db->dirty = 1; db->open = 1; - db->sub_curr = NULL; - db->sub_count = 0; - + db->ps_curr = NULL; + db->ps_count = 0; return (OK); } @@ -57,11 +55,8 @@ int c; int cnt; int status; - struct pkgdb_sub *sub; struct dirent **ents; -#if 0 - struct pkg_dir *pkg_list; -#endif + struct pkg_sub *ps_list; #if 0 if (!VALID_DB(db)) #endif @@ -74,95 +69,70 @@ if (c < 1) return (NOT_OK | MEMORY_ERR); -#if 0 - pkg_list = calloc(c, sizeof(*pkg_list)); - if (pkg_list = NULL) + ps_list = calloc(c, sizeof(*ps_list)); + if (ps_list == NULL) return (NOT_OK | MEMORY_ERR); - for i = 0, cnt = 0; i < c; ++i) { - status |= pkg_sub_init(db, pkg_list[i], ents[i]->d_name); - if (PKG_SUB_MEMORY_ERR(status)) { + for (i = 0, cnt = 0; i < c; ++i) { + if (ents[i]->d_type != DT_DIR) { + --cnt; + continue; + } + status |= pkg_sub_init(ps_list + i, db, ents[i]->d_name); + if (PKG_SUB_MEM_ERR(status)) { pkgdb_pkg_sub_list_free(db); for (; i < c; ++i) free(ents[i]); free(ents); - return (PKGDB_NOT_OK | PKGDB_MEMORY_ERR); + return (DB_NOT_OK | DB_MEMORY_ERR); } free(ents[i]); } free(ents); -#endif - - pkgdb_pkgdb_sub_list_init(db); - for (i = 0, cnt = 0; i < c; ++i) { - sub = pkgdb_sub_new(); - status = pkgdb_hierdb_read_pkgdb_sub(db, sub, ents[i]->d_name); - if (MEMORY_ERR & status) { - /* Ruh roh Shaggy! */ - pkgdb_pkgdb_sub_list_free(db); - for (; i < c; ++i) - free(ents[i]); - free(ents); - return (MEMORY_ERR); - } else if ((SUB_NO_CONTENTS & status) || (BAD_IDENT & status)) - /* - * This is a directory that is of no use to us. I am - * enforcing strict rules on what is and isn't a package. If - * there is no plist, or the plist is empty, this is not a - * package, and we don't care about it. - */ - pkgdb_sub_delete(sub); - else { - pkgdb_pkgdb_sub_list_append(db, sub); - cnt++; - } - free(ents[i]); - } - free(ents); + db->ps_list = ps_list; - db->sub_curr = NULL; - db->sub_count = cnt; + db->ps_curr = NULL; + db->ps_count = cnt; db->dirty = 0; return (OK); } -/* This function will properly initialize a pkgdb_sub for a pkgdb to use. - * This includes setting db as the owner of dbs. */ int -pkgdb_hierdb_read_pkgdb_sub(struct pkgdb *db, struct pkgdb_sub *sub, +pkgdb_hierdb_read_pkg_sub(struct pkgdb *db, struct pkg_sub *ps, const char *ident) { int status; #if 0 /* The client doesn't know about the functions in this file. */ if (!VALID_DB(x)) +#endif + if (db == NULL) arg_rage_quit(__func__, "Not a valid database.", RAGE_AT_CLIENT); if (ident == NULL) arg_rage_quit(__func__, "Not a valid identification string.", RAGE_AT_CLIENT); -#endif - pkgdb_sub_reset(sub); + pkg_sub_reset(ps); status = OK; - status |= pkgdb_sub_set_ident(sub, ident); + status |= pkg_sub_set_ident(ps, ident); /* Directory is verified here. */ - status |= pkgdb_sub_set_assign_db(db, sub); + // status |= pkgdb_sub_set_assign_db(db, ps); if ((MEMORY_ERR & status) || (BAD_IDENT & status)) return (status); /* Hope you have your reading glasses on... */ status = OK; - status |= pkgdb_sub_read_file_to_text(sub, COMMENT_FILE) & + status |= pkg_sub_read_file_to_text(ps, COMMENT_FILE_ID) & (SUB_EMPTY_FILE | SUB_NO_FILE) ? SUB_NO_COMMENT : OK; - status |= pkgdb_sub_read_file_to_text(sub, CONTENTS_FILE) & + status |= pkg_sub_read_file_to_text(ps, CONTENTS_FILE_ID) & (SUB_EMPTY_FILE | SUB_NO_FILE) ? SUB_NO_CONTENTS : OK; - status |= pkgdb_sub_read_file_to_text(sub, DESC_FILE) & + status |= pkg_sub_read_file_to_text(ps, DESC_FILE_ID) & (SUB_EMPTY_FILE | SUB_NO_FILE) ? SUB_NO_DESC : OK; - status |= pkgdb_sub_read_file_to_text(sub, DISPLAY_FILE) & + status |= pkg_sub_read_file_to_text(ps, DISPLAY_FILE_ID) & (SUB_EMPTY_FILE | SUB_NO_FILE) ? SUB_NO_DISPLAY : OK; - status |= pkgdb_sub_read_file_to_text(sub, MTREE_DIRS_FILE) & + status |= pkg_sub_read_file_to_text(ps, MTREE_DIRS_FILE_ID) & (SUB_EMPTY_FILE | SUB_NO_FILE) ? SUB_NO_MTREE_DIRS : OK; - status |= pkgdb_sub_read_file_to_text(sub, REQUIRED_BY_FILE) & + status |= pkg_sub_read_file_to_text(ps, REQUIRED_BY_FILE_ID) & (SUB_EMPTY_FILE | SUB_NO_FILE) ? SUB_NO_REQUIRED_BY : OK; return (status); ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb.h#5 (text+ko) ==== @@ -2,12 +2,13 @@ #define __PKGDB_HIERDB_H__ #include "pkg.h" +#include "pkg_sub.h" int pkgdb_hierdb_db_open(struct pkgdb *db, const char *db_root); int pkgdb_hierdb_db_init(struct pkgdb *db); -int pkgdb_hierdb_read_pkgdb_sub(struct pkgdb *db, struct pkgdb_sub *dbs, +int pkgdb_hierdb_read_pkg_sub(struct pkgdb *db, struct pkg_sub *ps, const char *ident); /* int pkgdb_hierdb_db_close(struct pkgdb *db); */ ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_private.h#3 (text+ko) ==== @@ -3,8 +3,6 @@ #include <sys/queue.h> -#include "pkgdb_hierdb_pkgdb_sub.h" - struct pkgdb { int open; int type; @@ -13,13 +11,15 @@ char *db_root; - int sub_count; - struct pkgdb_sub *sub_curr; - - TAILQ_HEAD(sub_head, pkgdb_sub) sub_head; + int ps_count; + + struct pkg_sub *ps_curr; + struct pkg_sub *ps_list; int (*pkgdb_db_open) (struct pkgdb *db, const char *db_root); int (*pkgdb_db_init) (struct pkgdb *db); + int (*pkgdb_db_read_sub) (struct pkgdb *db, struct pkg_sub *ps, + const char *ident); int (*pkgdb_db_close) (struct pkgdb *db); int (*pkgdb_db_sync) (struct pkgdb *db); };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906270516.n5R5GrdH061033>