4 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
5 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
6 * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
7 * Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
8 * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
34 #include <sys/stat.h> /* struct stat */
37 #include <libintl.h> /* here so it doesn't need to be included elsewhere */
38 /* define _() as shortcut for gettext() */
39 #define _(str) dgettext ("libalpm", str)
44 #define ALLOC_FAIL(s) do { _alpm_log(PM_LOG_ERROR, _("alloc failure: could not allocate %zd bytes\n"), s); } while(0)
46 #define MALLOC(p, s, action) do { p = calloc(1, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
47 #define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
48 #define STRDUP(r, s, action) do { r = strdup(s); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } while(0)
50 #define FREE(p) do { if(p) { free(p); p = NULL; } } while(0)
52 #define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
54 int _alpm_makepath(const char *path
);
55 int _alpm_copyfile(const char *src
, const char *dest
);
56 char *_alpm_strtrim(char *str
);
57 char *_alpm_strreplace(const char *str
, const char *needle
, const char *replace
);
60 int _alpm_unpack(const char *archive
, const char *prefix
, const char *fn
);
61 int _alpm_rmrf(const char *path
);
62 int _alpm_logaction(unsigned short usesyslog
, FILE *f
, const char *fmt
, va_list args
);
63 int _alpm_ldconfig(const char *root
);
64 int _alpm_str_cmp(const void *s1
, const void *s2
);
65 char *_alpm_filecache_find(const char *filename
);
66 const char *_alpm_filecache_setup(void);
67 int _alpm_lstat(const char *path
, struct stat
*buf
);
69 #ifndef HAVE_STRVERSCMP
70 int strverscmp(const char *, const char *);
73 char *strsep(char **, const char *);
76 /* check exported library symbols with: nm -C -D <lib> */
77 #define SYMEXPORT __attribute__((visibility("default")))
78 #define SYMHIDDEN __attribute__((visibility("internal")))
80 /* max percent of package size to download deltas */
81 #define MAX_DELTA_RATIO 0.7
83 #endif /* _ALPM_UTIL_H */
85 /* vim: set ts=2 sw=2 noet: */