ipkg: add a simple progress bar while downloading
[oweals/opkg-lede.git] / ipkg_message.c
1 /* ipkg_message.c - the itsy package management system
2
3    Copyright (C) 2003 Daniele Nicolodi <daniele@grinta.net>
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2, or (at
8    your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14 */
15
16
17 #include "ipkg.h"
18 #include "ipkg_conf.h"
19 #include "ipkg_message.h"
20
21 #ifndef IPKG_LIB
22
23 void
24 ipkg_message (ipkg_conf_t * conf, message_level_t level, char *fmt, ...)
25 {
26         va_list ap;
27
28         if (conf && (conf->verbosity < level))
29         {
30                 return;
31         }
32         else
33         {
34
35                 va_start (ap, fmt);
36                 vprintf (fmt, ap);
37                 va_end (ap);
38         }
39 }
40
41 #else
42
43 #include "libipkg.h"
44
45 //#define ipkg_message(conf, level, fmt, arg...) ipkg_cb_message(conf, level, fmt, ## arg)
46
47 void
48 ipkg_message (ipkg_conf_t * conf, message_level_t level, char *fmt, ...)
49 {
50         va_list ap;
51         char ts[256];
52
53         if (ipkg_cb_message)
54         {
55                 va_start (ap, fmt);
56                 vsnprintf (ts,256,fmt, ap);
57                 va_end (ap);
58                 ipkg_cb_message(conf,level,ts);
59         }
60 }
61 #endif