main: add a stub for PKG_CONFIG_LOG (ref #88)

pull/100/head
William Pitcock 2016-07-10 14:53:15 -05:00
parent eb91ba560d
commit 8ccc10863c
1 changed files with 17 additions and 1 deletions

18
main.c
View File

@ -2,7 +2,7 @@
* main.c
* main() routine, printer functions
*
* Copyright (c) 2011, 2012, 2013 pkgconf authors (see AUTHORS).
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -57,6 +57,7 @@ static char *want_variable = NULL;
static char *sysroot_dir = NULL;
FILE *error_msgout = NULL;
FILE *logfile_out = NULL;
static bool
error_handler(const char *msg)
@ -553,6 +554,7 @@ usage(void)
printf(" --simulate simulate walking the calculated dependency graph\n");
printf(" --no-cache do not cache already seen packages when\n");
printf(" walking the dependency graph\n");
printf(" --log-file=filename write an audit log to a specified file\n");
printf("\nchecking specific pkg-config database entries:\n\n");
@ -601,6 +603,7 @@ main(int argc, char *argv[])
char *required_exact_module_version = NULL;
char *required_max_module_version = NULL;
char *required_module_version = NULL;
char *logfile_arg = NULL;
want_flags = 0;
@ -646,6 +649,7 @@ main(int argc, char *argv[])
{ "print-provides", no_argument, &want_flags, PKG_PROVIDES, },
{ "debug", no_argument, &want_flags, 0, },
{ "validate", no_argument, NULL, 0 },
{ "log-file", required_argument, NULL, 40 },
{ NULL, 0, NULL, 0 }
};
@ -674,6 +678,9 @@ main(int argc, char *argv[])
case 29:
required_max_module_version = pkg_optarg;
break;
case 40:
logfile_arg = pkg_optarg;
break;
case '?':
case ':':
return EXIT_FAILURE;
@ -771,6 +778,12 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
if (logfile_arg == NULL)
logfile_arg = getenv("PKG_CONFIG_LOG");
if (logfile_arg != NULL)
logfile_out = fopen(logfile_arg, "w");
if (required_module_version != NULL)
{
pkgconf_pkg_t *pkg;
@ -1025,5 +1038,8 @@ out:
pkgconf_tuple_free_global();
pkgconf_cache_free();
if (logfile_out != NULL)
fclose(logfile_out);
return ret;
}