summaryrefslogtreecommitdiffstats
path: root/libopkg/opkg_message.c
diff options
context:
space:
mode:
Diffstat (limited to 'libopkg/opkg_message.c')
-rw-r--r--libopkg/opkg_message.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/libopkg/opkg_message.c b/libopkg/opkg_message.c
index 33a9c90..a21a1a2 100644
--- a/libopkg/opkg_message.c
+++ b/libopkg/opkg_message.c
@@ -1,5 +1,6 @@
/* opkg_message.c - the opkg package management system
+ Copyright (C) 2009 Ubiq Technologies <graham.gower@gmail.com>
Copyright (C) 2003 Daniele Nicolodi <daniele@grinta.net>
This program is free software; you can redistribute it and/or
@@ -17,11 +18,63 @@
#include "includes.h"
#include "opkg_conf.h"
#include "opkg_message.h"
-#include "opkg_error.h"
-#include "opkg_utils.h"
+#include "libbb/libbb.h"
+
+struct errlist {
+ char *errmsg;
+ struct errlist *next;
+};
+
+static struct errlist *error_list_head, *error_list_tail;
+
+static void
+push_error_list(char *msg)
+{
+ struct errlist *e;
+
+ e = xcalloc(1, sizeof(struct errlist));
+ e->errmsg = xstrdup(msg);
+ e->next = NULL;
+
+ if (error_list_head) {
+ error_list_tail->next = e;
+ error_list_tail = e;
+ } else {
+ error_list_head = error_list_tail = e;
+ }
+}
+
+void
+free_error_list(void)
+{
+ struct errlist *err, *err_tmp;
+
+ err = error_list_head;
+ while (err != NULL) {
+ free(err->errmsg);
+ err_tmp = err;
+ err = err->next;
+ free(err_tmp);
+ }
+}
+
+void
+print_error_list(void)
+{
+ struct errlist *err = error_list_head;
+
+ if (err) {
+ printf("Collected errors:\n");
+ /* Here we print the errors collected and free the list */
+ while (err != NULL) {
+ printf(" * %s", err->errmsg);
+ err = err->next;
+ }
+ }
+}
void
-opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...)
+opkg_message (message_level_t level, const char *fmt, ...)
{
va_list ap;
@@ -30,7 +83,7 @@ opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...)
va_start (ap, fmt);
- if (level == OPKG_ERROR) {
+ if (level == ERROR) {
char msg[256];
vsnprintf(msg, 256, fmt, ap);
push_error_list(msg);