From owner-p4-projects@FreeBSD.ORG Sun Jun 7 06:52:00 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9D6B1106566B; Sun, 7 Jun 2009 06:52:00 +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 5CA9D1065674 for ; Sun, 7 Jun 2009 06:52:00 +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 13D7B8FC17 for ; Sun, 7 Jun 2009 06:52:00 +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 n576px4L048479 for ; Sun, 7 Jun 2009 06:51:59 GMT (envelope-from dforsyth@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n576pxJl048477 for perforce@freebsd.org; Sun, 7 Jun 2009 06:51:59 GMT (envelope-from dforsyth@FreeBSD.org) Date: Sun, 7 Jun 2009 06:51:59 GMT Message-Id: <200906070651.n576pxJl048477@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 163683 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: Sun, 07 Jun 2009 06:52:01 -0000 http://perforce.freebsd.org/chv.cgi?CH=163683 Change 163683 by dforsyth@squirrel on 2009/06/07 06:51:04 Took stray tailq init out of plist init. pkg_info will spit out a file list if it gets any argument. Affected files ... .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#9 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#9 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.c#4 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.h#4 edit .. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_private.h#5 edit .. //depot/projects/soc2009/dforsyth_libpkg/pkg_info/main.c#4 edit Differences ... ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#9 (text+ko) ==== @@ -3,6 +3,7 @@ #include #include "pkg_util.h" +#include "pkg_plist.h" #include "pkgdb.h" #include "pkg_private.h" #include "pkg.h" @@ -33,6 +34,9 @@ return (p); } +/* TODO: Can't copy string for some _set_ functions and then just point to + * the passed pkg_plist for _set_pkg_plist. */ + /* Set the short comment for this package */ struct pkg * pkg_set_comment(struct pkg *p, const char *comment) @@ -70,8 +74,13 @@ { if (p == NULL) return (NULL); + + if (is_it_empty(pl)) + printf("its empty in set_pkg_plist, before set\n"); p->plist = pl; + if (is_it_empty(pl)) + printf("its empty in set_pkg_plist, after set\n"); return (p); } @@ -99,33 +108,64 @@ pkg_name(struct pkg *p) { char *name; + name = pkg_plist_name(p->plist); return (name); } +char * +pkg_cwd(struct pkg *p) +{ + char *cwd; + + cwd = pkg_plist_cwd(p->plist); + + return (cwd); +} + +/* Doesn't work correctly yet. */ +char * +pkg_orgin(struct pkg *p) +{ + char *orgin; + + orgin = pkg_plist_orgin(p->plist); + + return (orgin); +} + /* Temporarily void. */ void -pkg_pkg_plist_init(struct pkg *p) +pkg_file_list_init(struct pkg *p) { if (p == NULL) return; - pkg_plist_init(p->plist); - return; + if (is_it_empty(p->plist)) + printf("its empty when pkg requests init\n"); + + pkg_plist_file_list_init(p->plist); + if (is_it_empty(p->plist)) + printf("its empty when pkg requests init, after\n"); } /* Temporarily char. */ char * -pkg_pkg_plist_next(struct pkg *p) +pkg_file_list_next(struct pkg *p) { + struct pl_entry *ent; char *file_name; if (p == NULL) return (NULL); + + if (is_it_empty(p->plist)) + printf("its empty when pkg requests next\n"); + + ent = pkg_plist_file_list_next(p->plist); + file_name = pl_entry_info(ent); - file_name = pkg_plist_next(p->plist); - return (file_name); } ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.h#9 (text+ko) ==== @@ -1,6 +1,14 @@ #ifndef __PKG_H__ #define __PKG_H__ +/* pkg_plist */ + +struct pkg_plist; + +struct pkg_plist *pkg_plist_new(void); + +struct pkg_plist *pkg_plist_new_from_text(const char *text); + /* pkg */ struct pkg; @@ -17,11 +25,15 @@ char *pkg_name(struct pkg *p); +char *pkg_cwd(struct pkg *p); + +char *pkg_orgin(struct pkg *p); + char *pkg_comment(struct pkg *p); -void pkg_pkg_plist_init(struct pkg *p); +void pkg_file_list_init(struct pkg *p); -char *pkg_pkg_plist_next(struct pkg *p); +char *pkg_file_list_next(struct pkg *p); void pkg_free(struct pkg *p); @@ -43,12 +55,4 @@ void pkgdb_free_hierdb(struct pkgdb *db); -/* pkg_plist */ - -struct pkg_plist; - -struct pkg_plist *pkg_plist_new(void); - -struct pkg_plist *pkg_plist_new_from_text(const char *text); - #endif ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.c#4 (text+ko) ==== @@ -13,20 +13,6 @@ #include "pkgdb.h" #include "pkg.h" -/* For tracking mode, if the last file needs an MD5, owner, and group. */ - -struct file_state { - int last_needs_md5; - char *mode; - char *owner; - char *group; -}; - -struct pl_file { - /* Need a specific type for files because there so much stuff I can - * set... */ -}; - struct pl_entry { enum plist_elem type; char *info; @@ -46,8 +32,6 @@ char *text; /* The entire plist */ - struct file_state f_s; - struct pl_entry *file_curr; /* Use these lists here so that appending to our list doesnt need a @@ -55,13 +39,6 @@ * that want to build plists on the fly, modify plists, etc. */ TAILQ_HEAD(file_head, pl_entry) file_head; /* File list. */ - - /* This list organization needs to be sorted out... */ - - TAILQ_HEAD(exex_head, pl_entry) exec_head; /* Exec list. */ - TAILQ_HEAD(unexex_head, pl_entry) unexec_head; /* Unexec/dirrm list. */ - TAILQ_HEAD(cfl_head, pl_entry) cfl_head; /* Conflict list. */ - TAILQ_HEAD(opt_head, pl_entry) opt_head; /* Options list (for all 2) */ }; struct pkg_plist * @@ -121,6 +98,8 @@ textp = strdup(text); if (textp == NULL) return (NULL); + + pl->text = textp; pkg_plist_plist_init(pl); for (p = textp; *p != '\0'; p++) { @@ -128,13 +107,20 @@ line = textp; line[p - textp] = '\0'; ent = pkg_plist_parse_line(pl, line); - /* For now, just shove everything onto the main list. */ + + /* For now, just plop everything onto the file list. */ + /* TODO: have the append function sort entry types to the + * correct list. */ + if (ent != NULL) pkg_plist_plist_append(pl, ent); textp = p + 1; } } + if (is_it_empty(pl)) + printf("its empty in the parse.\n"); + return (pl); } @@ -149,11 +135,6 @@ if (line == NULL) return (NULL); - /* - ent = calloc(1, sizeof(*ent)); - if (ent == NULL) - return (NULL); - */ if (*line == '@') { sep = strchr(line, ' '); if (sep == NULL) @@ -161,14 +142,15 @@ *sep = '\0'; /* chop. */ command = line + 1; argument = sep + 1; - // ent->option = NULL; - /* Until I have the list organization sorted, just return entries - * and plop them on the main list. */ if (strcmp(command, PLIST_CMD_CWD) == 0 || - strcmp(command, PLIST_CMD_CD) == 0) + strcmp(command, PLIST_CMD_CD) == 0) { pl->cwd = argument; - else if (strcmp(command, PLIST_CMD_SRCDIR) == 0) + return (NULL); + } + else if (strcmp(command, PLIST_CMD_SRCDIR) == 0) { pl->srcdir = argument; + return (NULL); + } else if (strcmp(command, PLIST_CMD_EXEC) == 0) ent = pl_entry_new(PLIST_EXEC, argument, NULL); else if (strcmp(command, PLIST_CMD_UNEXEC) == 0) @@ -181,8 +163,11 @@ ent = pl_entry_new(PLIST_OWNER, argument, NULL); else if (strcmp(command, PLIST_CMD_GROUP) == 0) ent = pl_entry_new(PLIST_GROUP, argument, NULL); - else if (strcmp(command, PLIST_CMD_COMMENT) == 0) + else if (strcmp(command, PLIST_CMD_COMMENT) == 0) { + /* Lots more stuff needs to go in here... what a terrible file + * format... */ ent = pl_entry_new(PLIST_COMMENT, argument, NULL); + } else if (strcmp(command, PLIST_CMD_NOINST) == 0) { if ((sep = strchr(argument, ' ')) != NULL) *sep = '\0'; @@ -191,21 +176,23 @@ ent = pl_entry_new(PLIST_IGNORE, argument, NULL); else if (strcmp(command, PLIST_CMD_IGNORE_INST) == 0) ent = pl_entry_new(PLIST_IGNORE_INST, argument, NULL); - else if (strcmp(command, PLIST_CMD_NAME) == 0) + else if (strcmp(command, PLIST_CMD_NAME) == 0) { pl->name = argument; + return (NULL); + } else if (strcmp(command, PLIST_CMD_DIRRM) == 0) ent = pl_entry_new(PLIST_DIRRM, argument, NULL); - else if (strcmp(command, PLIST_CMD_MTREE) == 0) + else if (strcmp(command, PLIST_CMD_MTREE) == 0) { pl->mtree_file = argument; - else if (strcmp(command, PLIST_CMD_DISPLAY) == 0) + return (NULL); + } + else if (strcmp(command, PLIST_CMD_DISPLAY) == 0) { pl->display = argument; + return (NULL); + } else { /* If we cant identify the command, set it unknown and gather * whatever information we can. */ - /* - ent->type = PLIST_UNKNOWN; - ent->info = command; - */ ent = pl_entry_new(PLIST_UNKNOWN, argument, NULL); } } else { @@ -217,34 +204,31 @@ /* Temporarily void. */ void -pkg_plist_init(struct pkg_plist *pl) +pkg_plist_file_list_init(struct pkg_plist *pl) { /* Available to the client. */ - pkg_plist_plist_init(pl); + + /* If you init again, it clears the list. So don't. */ pl->file_curr = NULL; } -/* Temporarily char. At this point, only return file names of PLIST_FILE - * entries, just for some basic testing. */ -char * -pkg_plist_next(struct pkg_plist *pl) +struct pl_entry * +pkg_plist_file_list_next(struct pkg_plist *pl) { struct pl_entry *ent; if (pl == NULL) return (NULL); - - if (pl->file_curr == NULL) + + if (pl->file_curr == NULL) ent = pkg_plist_plist_first(pl); else ent = TAILQ_NEXT(pl->file_curr, next); - if (ent != NULL) { + if (ent != NULL) pl->file_curr = ent; - return (ent->info); - } - return (NULL); + return (ent); } char * @@ -256,6 +240,33 @@ return (pl->name); } +char * +pkg_plist_cwd(struct pkg_plist *pl) +{ + if (pl == NULL) + return (NULL); + + return (pl->cwd); +} + +char * +pkg_plist_orgin(struct pkg_plist *pl) +{ + if (pl == NULL) + return (NULL); + + return (pl->orgin); +} + +char * +pl_entry_info(struct pl_entry *ent) +{ + if (ent == NULL) + return (NULL); + + return (ent->info); +} + /* Don't know if I'll be sticking with this, so... */ void @@ -281,7 +292,16 @@ { if (pl == NULL || ent == NULL) return; + if (ent->type == PLIST_FILE) + TAILQ_INSERT_TAIL(&pl->file_head, ent, next); +} - TAILQ_INSERT_TAIL(&pl->file_head, ent, next); +int +is_it_empty(struct pkg_plist *pl) +{ + if (TAILQ_EMPTY(&pl->file_head)) + return (1); + + return (0); } ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.h#4 (text+ko) ==== @@ -1,12 +1,5 @@ -#ifndef __PKG_INFO_H__ -#define __PKG_INFO_H__ - -#define COMMENT_FILE "+COMMENT" -#define CONTENTS_FILE "+CONTENTS" -#define DESC_FILE "+DESC" -#define DISPLAY_FILE "+DISPLAY" -#define MTREE_DIRS_FILE "+MTREE_DIRS" -#define REQUIRED_BY_FILE "+REQUIRED_BY" +#ifndef __PKG_PLIST_H__ +#define __PKG_PLIST_H__ /* Make these visible to the client. */ enum plist_elem { @@ -54,13 +47,20 @@ struct pl_entry; +struct pl_entry * +pl_entry_new(enum plist_elem elem, char *info, char *option); + struct pkg_plist *pkg_plist_parse_contents_from_text(const char *text); struct pl_entry *pkg_plist_parse_line(struct pkg_plist *pl, char *line); -void pkg_plist_init(struct pkg_plist *pl); -char *pkg_plist_next(struct pkg_plist *pl); +void pkg_plist_file_list_init(struct pkg_plist *pl); +struct pl_entry *pkg_plist_file_list_next(struct pkg_plist *pl); char *pkg_plist_name(struct pkg_plist *pl); +char *pkg_plist_cwd(struct pkg_plist *pl); +char *pkg_plist_orgin(struct pkg_plist *pl); + +char *pl_entry_info(struct pl_entry *ent); void pkg_plist_plist_init(struct pkg_plist *pl); struct pl_entry *pkg_plist_plist_first(struct pkg_plist *pl); ==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_private.h#5 (text+ko) ==== @@ -1,6 +1,13 @@ #ifndef __PKG_PRIVATE_H__ #define __PKG_PRIVATE_H__ +#define COMMENT_FILE "+COMMENT" +#define CONTENTS_FILE "+CONTENTS" +#define DESC_FILE "+DESC" +#define DISPLAY_FILE "+DISPLAY" +#define MTREE_DIRS_FILE "+MTREE_DIRS" +#define REQUIRED_BY_FILE "+REQUIRED_BY" + struct pkg { TAILQ_ENTRY(pkg) next; ==== //depot/projects/soc2009/dforsyth_libpkg/pkg_info/main.c#4 (text+ko) ==== @@ -64,9 +64,12 @@ { /* pointlessly set this. */ opt_all = 1; - + char **a; + if (argc == 1) return; + + a = argv; /* give argv something to do. */ opt_show_all_info = 1; } @@ -105,10 +108,13 @@ printf("%s %s\n", pkg_name(p), pkg_comment(p)); else { /* Testing plist interaction. */ - printf("Package %s contains:\n", pkg_name(p)); - pkg_pkg_plist_init(p); - while ((file_name = pkg_pkg_plist_next(p)) != NULL) { - printf("\t%s\n", file_name); + printf("%s:\n", pkg_name(p)); + printf("\tcwd: %s\n", pkg_cwd(p)); + printf("\torgin: %s\n", pkg_orgin(p)); + printf("\tplist:\n"); + pkg_file_list_init(p); + while ((file_name = pkg_file_list_next(p)) != NULL) { + printf("\t\t%s\n", file_name); } } }