libalpm
Arch Linux Package Manager Library
util.h
Go to the documentation of this file.
00001 /*
00002  *  util.h
00003  *
00004  *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
00005  *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 #ifndef _PM_UTIL_H
00021 #define _PM_UTIL_H
00022 
00023 #include <stdlib.h>
00024 #include <stdarg.h>
00025 #include <string.h>
00026 
00027 #include <alpm_list.h>
00028 
00029 #ifdef ENABLE_NLS
00030 #include <libintl.h> /* here so it doesn't need to be included elsewhere */
00031 /* define _() as shortcut for gettext() */
00032 #define _(str) gettext(str)
00033 #define _n(str1, str2, ct) ngettext(str1, str2, ct)
00034 #else
00035 #define _(str) str
00036 #define _n(str1, str2, ct) (ct == 1 ? str1 : str2)
00037 #endif
00038 
00039 typedef struct _pm_target_t {
00040     alpm_pkg_t *remove;
00041     alpm_pkg_t *install;
00042     int is_explicit;
00043 } pm_target_t;
00044 
00045 void trans_init_error(void);
00046 int trans_init(alpm_transflag_t flags, int check_valid);
00047 int trans_release(void);
00048 int needs_root(void);
00049 int check_syncdbs(size_t need_repos, int check_valid);
00050 unsigned short getcols(void);
00051 int rmrf(const char *path);
00052 const char *mbasename(const char *path);
00053 char *mdirname(const char *path);
00054 void indentprint(const char *str, size_t indent);
00055 char *strtoupper(char *str);
00056 size_t strtrim(char *str);
00057 char *strreplace(const char *str, const char *needle, const char *replace);
00058 alpm_list_t *strsplit(const char *str, const char splitchar);
00059 void string_display(const char *title, const char *string);
00060 double humanize_size(off_t bytes, const char target_unit, const char **label);
00061 int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows);
00062 void list_display(const char *title, const alpm_list_t *list);
00063 void list_display_linebreak(const char *title, const alpm_list_t *list);
00064 void signature_display(const char *title, alpm_siglist_t *siglist);
00065 void display_targets(void);
00066 int str_cmp(const void *s1, const void *s2);
00067 void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg);
00068 void display_optdepends(alpm_pkg_t *pkg);
00069 void print_packages(const alpm_list_t *packages);
00070 void select_display(const alpm_list_t *pkglist);
00071 int select_question(int count);
00072 int multiselect_question(char *array, int count);
00073 int yesno(char *fmt, ...);
00074 int noyes(char *fmt, ...);
00075 
00076 int pm_printf(alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
00077 int pm_asprintf(char **string, const char *format, ...);
00078 int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
00079 int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
00080 
00081 #ifndef HAVE_STRNDUP
00082 char *strndup(const char *s, size_t n);
00083 #endif
00084 
00085 #endif /* _PM_UTIL_H */
00086 
00087 /* vim: set ts=2 sw=2 noet: */