1 /* opkg_message.c - the opkg package management system
3 Copyright (C) 2009 Ubiq Technologies <graham.gower@gmail.com>
4 Copyright (C) 2003 Daniele Nicolodi <daniele@grinta.net>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2, or (at
9 your option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
19 #include "opkg_conf.h"
20 #include "opkg_message.h"
21 #include "libbb/libbb.h"
28 static struct errlist *error_list_head, *error_list_tail;
31 push_error_list(char *msg)
35 e = xcalloc(1, sizeof(struct errlist));
36 e->errmsg = xstrdup(msg);
39 if (error_list_head) {
40 error_list_tail->next = e;
43 error_list_head = error_list_tail = e;
50 struct errlist *err, *err_tmp;
52 err = error_list_head;
62 print_error_list(void)
64 struct errlist *err = error_list_head;
67 printf("Collected errors:\n");
68 /* Here we print the errors collected and free the list */
70 printf(" * %s", err->errmsg);
77 opkg_message (message_level_t level, const char *fmt, ...)
81 if (conf->verbosity < level)
84 if (conf->opkg_vmessage) {
85 /* Pass the message to libopkg users. */
87 conf->opkg_vmessage(level, fmt, ap);
97 if (vsnprintf(msg, MSG_LEN, fmt, ap) >= MSG_LEN) {
98 fprintf(stderr, "%s: Message truncated!\n",
101 push_error_list(msg);