From owner-p4-projects@FreeBSD.ORG Thu Jun 11 16:06:22 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 458A01065676; Thu, 11 Jun 2009 16:06:22 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F310F106566B for ; Thu, 11 Jun 2009 16:06:21 +0000 (UTC) (envelope-from dforsyth@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E03EC8FC15 for ; Thu, 11 Jun 2009 16:06:21 +0000 (UTC) (envelope-from dforsyth@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n5BG6LWj088824 for ; Thu, 11 Jun 2009 16:06:21 GMT (envelope-from dforsyth@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5BG6LhT088822 for perforce@freebsd.org; Thu, 11 Jun 2009 16:06:21 GMT (envelope-from dforsyth@FreeBSD.org) Date: Thu, 11 Jun 2009 16:06:21 GMT Message-Id: <200906111606.n5BG6LhT088822@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to dforsyth@FreeBSD.org using -f From: David Forsythe To: Perforce Change Reviews Cc: Subject: PERFORCE change 164116 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2009 16:06:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=164116 Change 164116 by dforsyth@squirrel on 2009/06/11 16:05:42 Changed pkg.h to reflect current API design. Moving pkgdb_sub into pkg. Affected files ... .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#14 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#14 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_private.h#9 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb_pkgdb_sub.c#3 edit Differences ... ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#14 (text+ko) ==== @@ -10,6 +10,22 @@ #include "pkg_private.h" #include "pkg.h" +struct pkg { + char *ident; /* User given name for this pkg. */ + char *comment_text; + char *contents_text; + char *desc_text; + char *display_text; + char *mtree_dirs_text; + char *required_by_text; + + struct pkg_plist plist; + + TAILQ_ENTRY(pkg) next; + short dirty; + /* Add an owner field? */ +}; + /* Create a new pkg. */ struct pkg * @@ -50,46 +66,15 @@ * the passed pkg_plist for _set_pkg_plist. */ /* Set the short comment for this package */ -struct pkg * +int pkg_set_comment(struct pkg *p, const char *comment) { - int c; - char *f; - if (p == NULL) - return (p); + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); - if (comment == NULL) { - /* embrace it... */ - p->comment = NULL; - return (p); - } + p->comment_text = comment; - p->comment = strdup(comment); - if (p->comment == NULL) { - /* Something bad happened... I should probably let people know - * about it... */ - return (p); - } - - /* Blot out a trailing '\n'. */ - c = (int) '\n'; - f = strrchr(p->comment, c); - if (f != NULL) - *f = '\0'; - - return (p); -} - -struct pkg * -pkg_set_pkg_plist(struct pkg *p, struct pkg_plist *pl) -{ - if (p == NULL) - return (NULL); - - p->plist = pl; - - return (p); + return (PKG_OK); } /* ident and name are different, even though they might be the same. */ @@ -97,7 +82,7 @@ pkg_ident(struct pkg *p) { if (p == NULL) - return (NULL); + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); return (p->ident); } @@ -106,61 +91,52 @@ pkg_comment(struct pkg *p) { if (p == NULL) - return (NULL); + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); return (p->comment); } -/* Function to access information stored in the pkg_plist. */ +/* Functions to access information stored in the pkg_plist. */ char * pkg_name(struct pkg *p) { - char *name; - - name = pkg_plist_name(p->plist); - - return (name); + return (pkg_plist_name(&p->plist)); } char * pkg_cwd(struct pkg *p) { - char *cwd; - - cwd = pkg_plist_cwd(p->plist); - - return (cwd); + if (p == NULL) + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); + + return (pkg_plist_cwd(p->plist)); } -/* Doesn't work correctly yet. */ char * pkg_origin(struct pkg *p) { - char *origin; - - origin = pkg_plist_origin(p->plist); - - return (origin); + if (p == NULL) + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); + + return (pkg_plist_origin(p->plist)) } -/* Temporarily void. */ void pkg_file_list_init(struct pkg *p) { if (p == NULL) - return; + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); pkg_plist_pkg_file_list_reset(p->plist); } -/* Temporarily char. */ struct pkg_file * pkg_file_list_next(struct pkg *p) { struct pkg_file *pf; if (p == NULL) - return (NULL); + arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT); pf = pkg_plist_pkg_file_list_next(p->plist); ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#14 (text+ko) ==== @@ -10,40 +10,32 @@ struct pkg_file; +struct pkg_file *pkg_file_new(); + const char *pkg_file_path(struct pkg_file *pf); const char *pkg_file_md5(struct pkg_file *pf); -/* These might not be client accessible since they're really only useful - * when reading a plist. A client creating a plist should already have - * this information. */ const char *pkg_file_owner(struct pkg_file *pf); const char *pkg_file_group(struct pkg_file *pf); +int pkg_file_set_path(struct pkg_file *pf, const char *path); -/* TODO: Get pkg_plist out of here. */ +int pkg_file_set_md5(struct pkg_file *pf, const char *md5); -/* pkg_plist */ +int pkg_file_set_owner(struct pkg_file *pf, const char *owner); -struct pkg_plist; +int pkg_file_set_group(struct pkg_file *pf, const char *group); -struct pkg_plist *pkg_plist_new(void); +/* pkg */ -struct pkg_plist *pkg_plist_new_from_text(const char *text); - -/* pkg */ +/* Add mtree stuff later. */ struct pkg; struct pkg *pkg_new(const char *ident); -struct pkg *pkg_set_path(struct pkg *p, const char *path); - -struct pkg *pkg_set_comment(struct pkg *p, const char *comment); - -struct pkg *pkg_set_pkg_plist(struct pkg *p, struct pkg_plist *pl); - char *pkg_ident(struct pkg *p); char *pkg_name(struct pkg *p); @@ -54,30 +46,58 @@ char *pkg_comment(struct pkg *p); -void pkg_file_list_init(struct pkg *p); +char *pkg_description(struct pkg *p); + +char *pkg_display(struct pkg *p); + +int pkg_set_ident(struct pkg *p, const char *ident); + +int pkg_set_name(struct pkg *p, const char *name); + +int pkg_set_cwd(struct pkg *p, const char *cwd); + +int pkg_set_orgin(struct pkg *p, const char *orgin); + +int pkg_set_comment(struct pkg *p, const char *comment); + +int pkg_set_description(struct pkg *p, const char *description); + +int pkg_set_display(struct pkg *p, const char *display); + +int pkg_parse_plist(struct pkg *p); + +int pkg_pkg_file_list_next(struct pkg *p, struct pkg_file *pf); + +int pkg_pkg_file_list_reset(struct pkg *p); + +int pkg_pkg_file_add(struct pkg *p, struct pkg_file *pf); -struct pkg_file *pkg_file_list_next(struct pkg *p); +int pkg_pkg_file_remove(struct pkg *p, struct pkg_file *pf); -void pkg_free(struct pkg *p); +void pkg_delete(struct pkg *p); /* pkgdb */ struct pkgdb; -struct pkgdb *pkgdb_read_db_hierdb(const char *db_root); +struct pkgdb *pkgdb_new(); /* Should eventually take a type argument. */ + +int pkgdb *pkgdb_db_open(struct pkgdb *db, const char *db_root); -int pkgdb_init_db_hierdb(struct pkgdb *db); +int pkgdb *pkgdb_db_init(struct pkgdb *db); -struct pkg *pkgdb_read_pkg_hierdb(struct pkgdb *db, const char *ident); +int pkgdb *pkgdb_db_close(struct pkgdb *db); -struct pkg *pkgdb_next_pkg(struct pkgdb *db); +int pkgdb_pkg_next(struct pkgdb *db, struct pkg *p); -struct pkg *pkgdb_curr_pkg(struct pkgdb *db); +int pkgdb_pkg_get(struct pkgdb *db, struct pkg *p, const char *ident); -struct pkg *pkgdb_query_pkg(struct pkgdb *db, const char *ident); +#if 0 +int pkgdb_pkg_put(struct pkgdb *db, struct pkg *p); -char *pkgdb_pkg_path(struct pkgdb *db, struct pkg *p); +int pkgdb_db_sync(struct pkgdb *db); +#endif -void pkgdb_free_hierdb(struct pkgdb *db); +void pkgdb_delete(struct pkgdb *db); #endif ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_private.h#9 (text+ko) ==== @@ -8,12 +8,5 @@ #define MTREE_DIRS_FILE "+MTREE_DIRS" #define REQUIRED_BY_FILE "+REQUIRED_BY" -struct pkg { - char *ident; /* User given name for this pkg. */ - char *comment; /* Mmmmm, should be 70 or less, right? */ - struct pkg_plist *plist; - - TAILQ_ENTRY(pkg) next; -}; #endif ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb_pkgdb_sub.c#3 (text+ko) ==== @@ -138,6 +138,7 @@ return; free(dbs->ident); + free(dbs->path); free(dbs->comment_text); free(dbs->contents_text); free(dbs->desc_text); @@ -145,6 +146,7 @@ free(dbs->mtree_dirs_text); free(dbs->required_by_text); dbs->ident = NULL; + dbs->path = NULL; dbs->comment_text = NULL; dbs->contents_text = NULL; dbs->desc_text = NULL;