void opkg_message(message_level_t level, const char *fmt, ...) { va_list ap; if (opkg_config->verbosity < (int)level) return; if (opkg_config->opkg_vmessage) { /* Pass the message to libopkg users. */ va_start(ap, fmt); opkg_config->opkg_vmessage(level, fmt, ap); va_end(ap); return; } va_start(ap, fmt); if (level == ERROR) { #define MSG_LEN 4096 char msg[MSG_LEN]; int ret; ret = vsnprintf(msg, MSG_LEN, fmt, ap); if (ret < 0) { fprintf(stderr, "%s: encountered an output or encoding" " error during vsnprintf.\n", __FUNCTION__); va_end(ap); exit(EXIT_FAILURE); } if (ret >= MSG_LEN) { fprintf(stderr, "%s: Message truncated.\n", __FUNCTION__); } push_error_list(msg); } else { int ret; ret = vprintf(fmt, ap); if (ret < 0) { fprintf(stderr, "%s: encountered an output or encoding" " error during vprintf.\n", __FUNCTION__); exit(EXIT_FAILURE); } } va_end(ap); }
void targz_message (message_level_t level, const char *fmt, ...) { va_list ap; va_start (ap, fmt); if (level == ERROR) { #define MSG_LEN 4096 char msg[MSG_LEN]; int ret; ret = vsnprintf(msg, MSG_LEN, fmt, ap); if (ret < 0) { fprintf(stderr, "%s: encountered an output or encoding" " error during vsnprintf.\n", __FUNCTION__); va_end (ap); exit(EXIT_FAILURE); } if (ret >= MSG_LEN) { fprintf(stderr, "%s: Message truncated.\n", __FUNCTION__); } push_error_list(msg); } else { if (vprintf(fmt, ap) < 0) { fprintf(stderr, "%s: encountered an output or encoding" " error during vprintf.\n", __FUNCTION__); exit(EXIT_FAILURE); } } va_end (ap); }