From cebb308ce4757a5d2ed5501157e8521a1f3ca999 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Sun, 23 Mar 2008 20:51:50 +0100 Subject: [PATCH] 2008-03-23 Tollef Fog Heen * main.c (main): Add logging support from NetBSD. Thanks to Julio M. Merino Vidal for forwarding the patch from ages ago. --- ChangeLog | 5 +++++ main.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 31498ef..ab22df0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-23 Tollef Fog Heen + + * main.c (main): Add logging support from NetBSD. Thanks to Julio + M. Merino Vidal for forwarding the patch from ages ago. + 2008-03-23 Stepan Kasal * pkg-config.1: Document "Requires.private" and recommend it diff --git a/main.c b/main.c index 253623d..5ccb312 100644 --- a/main.c +++ b/main.c @@ -206,7 +206,7 @@ main (int argc, char **argv) char **search_dirs; char **iter; gboolean need_newline; - + FILE *log; const char *pkgname; Package *pkg; @@ -421,6 +421,17 @@ main (int argc, char **argv) g_strstrip (str->str); + if (getenv("PKG_CONFIG_LOG") != NULL) + { + log = fopen (getenv ("PKG_CONFIG_LOG"), "a"); + if (log == NULL) + { + fprintf (stderr, "Cannot open log file: %s\n", + getenv ("PKG_CONFIG_LOG")); + exit (1); + } + } + { gboolean failed = FALSE; GSList *reqs; @@ -441,6 +452,17 @@ main (int argc, char **argv) else req = get_package (ver->name); + if (log != NULL) + { + if (req == NULL) + fprintf (log, "%s NOT-FOUND", ver->name); + else + fprintf (log, "%s %s %s", ver->name, + comparison_to_str (ver->comparison), + (ver->version == NULL) ? "(null)" : ver->version); + fprintf (log, "\n"); + } + if (req == NULL) { failed = TRUE; @@ -471,6 +493,11 @@ main (int argc, char **argv) iter = g_slist_next (iter); } + if (log != NULL) + { + fclose (log); + } + if (failed) { return 1; } -- 2.39.5