index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2007-12-08 23:42:04 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-12-09 11:33:08 -0600 |
commit | 7249c08bdf6beacc087607db558ef16d3527b9b6 (patch) | |
tree | 4083daddba67c0864d2b6dce5c9b4587caa94b65 /src/pacman/package.c | |
parent | 815a2ead3ef2b8daedb9e93e5e141356d5003e6e (diff) |
-rw-r--r-- | src/pacman/package.c | 38 |
diff --git a/src/pacman/package.c b/src/pacman/package.c index ac3f8207..ba572141 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -34,6 +34,8 @@ #include "package.h" #include "util.h" +#define CLBUF_SIZE 4096 + /* Display the content of a package * * level: <0 - sync package [-Si] @@ -232,28 +234,30 @@ void dump_pkg_files(pmpkg_t *pkg) fflush(stdout); } -/* Display the changelog of an installed package +/* Display the changelog of a package */ -void dump_pkg_changelog(char *clfile, const char *pkgname) +void dump_pkg_changelog(pmpkg_t *pkg) { - FILE* fp = NULL; - char line[PATH_MAX+1]; + void *fp = NULL; - if((fp = fopen(clfile, "r")) == NULL) - { - fprintf(stderr, _("error: no changelog available for '%s'.\n"), pkgname); + if((fp = alpm_pkg_changelog_open(pkg)) == NULL) { + /* TODO after string freeze use pm_fprintf */ + fprintf(stderr, _("error: no changelog available for '%s'.\n"), + alpm_pkg_get_name(pkg)); return; - } - else - { - while(!feof(fp)) - { - fgets(line, (int)PATH_MAX, fp); - printf("%s", line); - line[0] = '\0'; + } else { + /* allocate a buffer to get the changelog back in chunks */ + char buf[CLBUF_SIZE]; + int ret = 0; + while((ret = alpm_pkg_changelog_read(buf, CLBUF_SIZE, pkg, fp))) { + if(ret < CLBUF_SIZE) { + /* if we hit the end of the file, we need to add a null terminator */ + *(buf + ret) = '\0'; + } + printf("%s", buf); } - fclose(fp); - return; + alpm_pkg_changelog_close(pkg, fp); + printf("\n"); } } |