From 2efe889d70142278c2091ee295fd0f8713ce20f2 Mon Sep 17 00:00:00 2001 From: silvio Date: Sat, 20 Dec 2008 06:51:59 +0100 Subject: [PATCH] Log commandline to logfile --- src/pacman/pacman.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 3255cdf..7424237 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -797,6 +797,36 @@ static int parseconfig(const char *file) return(_parseconfig(file, NULL, NULL)); } +/** print commandline to logfile + */ +static void cl_to_log(int argc, char* argv[]) { + char *cl_text = calloc(1,0); + int cl_text_size = 0; + + for(int cl_counter=0; cl_counter cl_text_new -> cl_text + cl_text_new = calloc(1, cl_text_size+cl_argv_size+1); + memcpy(cl_text_new, cl_text, cl_text_size); + free(cl_text); + cl_text = cl_text_new; + + // add new option + strncat(cl_text, cl_argv, cl_argv_size); + + // prevent ugly last space + if(cl_counter+1 < argc) + strncat(cl_text, " ", 1); + + cl_text_size += strlen(cl_text); + } + alpm_logaction("Starting pacman-action with '%s'\n", cl_text); + free(cl_text); +} + /** Main function. * @param argc argc * @param argv argv @@ -923,6 +953,9 @@ int main(int argc, char *argv[]) cleanup(EXIT_FAILURE); } + /* Log commandline */ + cl_to_log(argc, argv); + /* start the requested operation */ switch(config->op) { case PM_OP_REMOVE: -- 1.6.0.5