apk-tools/src/apk_print.h

59 lines
1.6 KiB
C
Raw Normal View History

2010-06-11 07:09:25 +00:00
/* apk_print.h - Alpine Package Keeper (APK)
2010-03-05 08:13:25 +00:00
*
* Copyright (C) 2005-2008 Natanael Copa <n@tanael.org>
2011-09-13 08:53:01 +00:00
* Copyright (C) 2008-2011 Timo Teräs <timo.teras@iki.fi>
2010-03-05 08:13:25 +00:00
* All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-only
2010-03-05 08:13:25 +00:00
*/
#ifndef APK_PRINT_H
#define APK_PRINT_H
#include "apk_blob.h"
struct apk_url_print {
const char *url;
const char *pwmask;
const char *url_or_host;
size_t len_before_pw;
};
void apk_url_parse(struct apk_url_print *, const char *);
#define URL_FMT "%.*s%s%s"
#define URL_PRINTF(u) u.len_before_pw, u.url, u.pwmask, u.url_or_host
#define apk_error(args...) do { apk_log_err("ERROR: ", args); } while (0)
#define apk_warning(args...) do { if (apk_verbosity > 0) { apk_log_err("WARNING: ", args); } } while (0)
2010-03-05 08:13:25 +00:00
#define apk_message(args...) do { if (apk_verbosity > 0) { apk_log(NULL, args); } } while (0)
void apk_log(const char *prefix, const char *format, ...);
void apk_log_err(const char *prefix, const char *format, ...);
2010-03-05 08:13:25 +00:00
const char *apk_error_str(int error);
void apk_reset_screen_width(void);
int apk_get_screen_width(void);
const char *apk_get_human_size(off_t size, off_t *dest);
struct apk_progress {
int fd;
FILE *out;
int last_bar, last_percent;
size_t last_done;
const char *progress_char;
};
void apk_print_progress(struct apk_progress *p, size_t done, size_t total);
struct apk_indent {
int x;
int indent;
};
int apk_print_indented(struct apk_indent *i, apk_blob_t blob);
2010-03-05 08:13:25 +00:00
void apk_print_indented_words(struct apk_indent *i, const char *text);
void apk_print_indented_fmt(struct apk_indent *i, const char *fmt, ...);
2010-03-05 08:13:25 +00:00
#endif