summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/package.c38
-rw-r--r--src/pacman/package.h2
-rw-r--r--src/pacman/query.c9
3 files changed, 23 insertions, 26 deletions
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");
}
}
diff --git a/src/pacman/package.h b/src/pacman/package.h
index 0e4bb0fa..7dfc0548 100644
--- a/src/pacman/package.h
+++ b/src/pacman/package.h
@@ -28,7 +28,7 @@ void dump_pkg_sync(pmpkg_t *pkg, const char *treename);
void dump_pkg_backups(pmpkg_t *pkg);
void dump_pkg_files(pmpkg_t *pkg);
-void dump_pkg_changelog(char *clfile, const char *pkgname);
+void dump_pkg_changelog(pmpkg_t *pkg);
#endif /* _PM_PACKAGE_H */
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 8a8765b6..13070772 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -312,14 +312,7 @@ static void display(pmpkg_t *pkg)
dump_pkg_files(pkg);
}
if(config->op_q_changelog) {
- char changelog[PATH_MAX];
- /* TODO should be done in the backend- no raw DB stuff up front */
- snprintf(changelog, PATH_MAX, "%s/%s/%s-%s/changelog",
- alpm_option_get_dbpath(),
- alpm_db_get_name(db_local),
- alpm_pkg_get_name(pkg),
- alpm_pkg_get_version(pkg));
- dump_pkg_changelog(changelog, alpm_pkg_get_name(pkg));
+ dump_pkg_changelog(pkg);
}
if(!config->op_q_info && !config->op_q_list && !config->op_q_changelog) {
if (!config->quiet) {