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;
30 static void push_error_list(char *msg)
34 e = xcalloc(1, sizeof(struct errlist));
35 e->errmsg = xstrdup(msg);
38 if (error_list_head) {
39 error_list_tail->next = e;
42 error_list_head = error_list_tail = e;
46 void free_error_list(void)
48 struct errlist *err, *err_tmp;
50 err = error_list_head;
59 void print_error_list(void)
61 struct errlist *err = error_list_head;
64 fprintf(stderr, "Collected errors:\n");
65 /* Here we print the errors collected and free the list */
67 fprintf(stderr, " * %s", err->errmsg);
73 void opkg_message(message_level_t level, const char *fmt, ...)
77 if (conf->verbosity < level)
80 if (conf->opkg_vmessage) {
81 /* Pass the message to libopkg users. */
83 conf->opkg_vmessage(level, fmt, ap);
94 ret = vsnprintf(msg, MSG_LEN, fmt, ap);
96 fprintf(stderr, "%s: encountered an output or encoding"
97 " error during vsnprintf.\n", __FUNCTION__);
101 if (ret >= MSG_LEN) {
102 fprintf(stderr, "%s: Message truncated.\n",
105 push_error_list(msg);
107 if (vprintf(fmt, ap) < 0) {
108 fprintf(stderr, "%s: encountered an output or encoding"
109 " error during vprintf.\n", __FUNCTION__);