2005-03-14 20:51:43 -05:00
|
|
|
/*
|
|
|
|
* util.h
|
2007-04-26 19:20:46 -04:00
|
|
|
*
|
2011-01-05 23:45:15 -05:00
|
|
|
* Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
|
2009-07-01 03:08:33 -04:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2007-04-26 19:20:46 -04:00
|
|
|
*
|
2005-03-14 20:51:43 -05:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-03-14 20:51:43 -05:00
|
|
|
*/
|
|
|
|
#ifndef _PM_UTIL_H
|
|
|
|
#define _PM_UTIL_H
|
|
|
|
|
2007-01-19 04:28:44 -05:00
|
|
|
#include <stdlib.h>
|
2007-06-12 16:09:46 -04:00
|
|
|
#include <stdarg.h>
|
2007-01-19 04:28:44 -05:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <alpm_list.h>
|
2006-03-13 15:34:47 -05:00
|
|
|
|
2007-04-26 19:39:53 -04:00
|
|
|
#ifdef ENABLE_NLS
|
2007-10-23 00:52:55 -04:00
|
|
|
#include <libintl.h> /* here so it doesn't need to be included elsewhere */
|
|
|
|
/* define _() as shortcut for gettext() */
|
2006-05-14 22:19:57 -04:00
|
|
|
#define _(str) gettext(str)
|
2010-07-27 16:50:43 -04:00
|
|
|
#define _n(str1, str2, ct) ngettext(str1, str2, ct)
|
2007-04-26 19:39:53 -04:00
|
|
|
#else
|
|
|
|
#define _(str) str
|
2010-07-27 16:50:43 -04:00
|
|
|
#define _n(str1, str2, ct) (ct == 1 ? str1 : str2)
|
2007-04-26 19:39:53 -04:00
|
|
|
#endif
|
2007-04-25 03:15:32 -04:00
|
|
|
|
2007-10-23 00:52:55 -04:00
|
|
|
/* update speed for the fill_progress based functions */
|
|
|
|
#define UPDATE_SPEED_SEC 0.2f
|
|
|
|
|
2011-07-22 13:01:58 -04:00
|
|
|
typedef struct _pm_target_t {
|
|
|
|
alpm_pkg_t *remove;
|
|
|
|
alpm_pkg_t *install;
|
2011-07-29 16:35:59 -04:00
|
|
|
int is_explicit;
|
2011-07-22 13:01:58 -04:00
|
|
|
} pm_target_t;
|
|
|
|
|
2011-08-29 12:58:48 -04:00
|
|
|
void trans_init_error(void);
|
2011-06-08 00:08:06 -04:00
|
|
|
int trans_init(alpm_transflag_t flags, int check_valid);
|
2008-09-20 11:09:17 -04:00
|
|
|
int trans_release(void);
|
2009-05-16 11:59:45 -04:00
|
|
|
int needs_root(void);
|
2011-06-08 00:08:06 -04:00
|
|
|
int check_syncdbs(size_t need_repos, int check_valid);
|
2011-09-28 10:44:15 -04:00
|
|
|
unsigned short getcols(void);
|
2007-05-31 02:51:28 -04:00
|
|
|
int rmrf(const char *path);
|
2011-01-22 15:20:42 -05:00
|
|
|
const char *mbasename(const char *path);
|
2008-02-05 19:49:13 -05:00
|
|
|
char *mdirname(const char *path);
|
2011-09-28 10:44:15 -04:00
|
|
|
void indentprint(const char *str, size_t indent);
|
2005-03-14 20:51:43 -05:00
|
|
|
char *strtoupper(char *str);
|
2006-03-13 15:34:47 -05:00
|
|
|
char *strtrim(char *str);
|
2007-06-04 12:01:53 -04:00
|
|
|
char *strreplace(const char *str, const char *needle, const char *replace);
|
2007-11-13 19:32:56 -05:00
|
|
|
alpm_list_t *strsplit(const char *str, const char splitchar);
|
2007-11-23 16:32:40 -05:00
|
|
|
void string_display(const char *title, const char *string);
|
2011-08-24 23:13:26 -04:00
|
|
|
double humanize_size(off_t bytes, const char target_unit, const char **label);
|
2011-02-19 17:23:42 -05:00
|
|
|
int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows);
|
2007-06-05 17:34:33 -04:00
|
|
|
void list_display(const char *title, const alpm_list_t *list);
|
2008-07-31 09:58:25 -04:00
|
|
|
void list_display_linebreak(const char *title, const alpm_list_t *list);
|
2011-08-24 14:24:42 -04:00
|
|
|
void signature_display(const char *title, alpm_siglist_t *siglist);
|
2011-07-22 13:01:58 -04:00
|
|
|
void display_targets(void);
|
2010-10-14 04:02:38 -04:00
|
|
|
int str_cmp(const void *s1, const void *s2);
|
2011-06-28 09:26:39 -04:00
|
|
|
void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg);
|
|
|
|
void display_optdepends(alpm_pkg_t *pkg);
|
2009-07-19 05:15:11 -04:00
|
|
|
void print_packages(const alpm_list_t *packages);
|
2010-10-16 06:28:01 -04:00
|
|
|
void select_display(const alpm_list_t *pkglist);
|
|
|
|
int select_question(int count);
|
2010-10-17 11:09:25 -04:00
|
|
|
int multiselect_question(char *array, int count);
|
2008-08-20 16:08:11 -04:00
|
|
|
int yesno(char *fmt, ...);
|
|
|
|
int noyes(char *fmt, ...);
|
2011-06-28 00:41:07 -04:00
|
|
|
int pm_printf(alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
|
|
|
|
int pm_fprintf(FILE *stream, alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));
|
2010-09-27 01:30:39 -04:00
|
|
|
int pm_asprintf(char **string, const char *format, ...);
|
2011-06-28 00:41:07 -04:00
|
|
|
int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
|
|
|
|
int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-10-24 01:37:50 -04:00
|
|
|
#ifndef HAVE_STRNDUP
|
|
|
|
char *strndup(const char *s, size_t n);
|
|
|
|
#endif
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
#endif /* _PM_UTIL_H */
|
|
|
|
|
|
|
|
/* vim: set ts=2 sw=2 noet: */
|