Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/util.h')
-rw-r--r--lib/libalpm/util.h48
1 files changed, 33 insertions, 15 deletions
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index c66e9881..d66ddee9 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -27,7 +27,9 @@
#include "config.h"
#include "alpm_list.h"
-#include "package.h" /* pmpkg_t */
+#include "alpm.h"
+#include "package.h" /* alpm_pkg_t */
+#include "handle.h" /* alpm_handle_t */
#include <stdio.h>
#include <string.h>
@@ -36,6 +38,8 @@
#include <time.h>
#include <sys/stat.h> /* struct stat */
#include <archive.h> /* struct archive */
+#include <math.h> /* fabs */
+#include <float.h> /* DBL_EPSILON */
#ifdef ENABLE_NLS
#include <libintl.h> /* here so it doesn't need to be included elsewhere */
@@ -45,7 +49,7 @@
#define _(s) s
#endif
-#define ALLOC_FAIL(s) do { _alpm_log(PM_LOG_ERROR, _("alloc failure: could not allocate %zd bytes\n"), s); } while(0)
+#define ALLOC_FAIL(s) do { fprintf(stderr, "alloc failure: could not allocate %zd bytes\n", s); } while(0)
#define MALLOC(p, s, action) do { p = calloc(1, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
#define CALLOC(p, l, s, action) do { p = calloc(l, s); if(p == NULL) { ALLOC_FAIL(s); action; } } while(0)
@@ -57,13 +61,19 @@
#define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
-#define RET_ERR_VOID(err) do { pm_errno = (err); \
- _alpm_log(PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerrorlast()); \
+#define RET_ERR_VOID(handle, err) do { \
+ _alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
+ (handle)->pm_errno = (err); \
return; } while(0)
-#define RET_ERR(err, ret) do { pm_errno = (err); \
- _alpm_log(PM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerrorlast()); \
- return(ret); } while(0)
+#define RET_ERR(handle, err, ret) do { \
+ _alpm_log(handle, ALPM_LOG_DEBUG, "returning error %d from %s : %s\n", err, __func__, alpm_strerror(err)); \
+ (handle)->pm_errno = (err); \
+ return (ret); } while(0)
+
+#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
+
+#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0)
/**
* Used as a buffer/state holder for _alpm_archive_fgets().
@@ -85,21 +95,27 @@ int _alpm_makepath(const char *path);
int _alpm_makepath_mode(const char *path, mode_t mode);
int _alpm_copyfile(const char *src, const char *dest);
char *_alpm_strtrim(char *str);
-int _alpm_unpack_single(const char *archive, const char *prefix, const char *fn);
-int _alpm_unpack(const char *archive, const char *prefix, alpm_list_t *list, int breakfirst);
+int _alpm_unpack_single(alpm_handle_t *handle, const char *archive,
+ const char *prefix, const char *filename);
+int _alpm_unpack(alpm_handle_t *handle, const char *archive, const char *prefix,
+ alpm_list_t *list, int breakfirst);
int _alpm_rmrf(const char *path);
-int _alpm_logaction(int usesyslog, FILE *f, const char *fmt, va_list args);
-int _alpm_run_chroot(const char *root, const char *path, char *const argv[]);
-int _alpm_ldconfig(const char *root);
+ssize_t _alpm_files_in_directory(alpm_handle_t *handle, const char *path, int full_count);
+int _alpm_logaction(alpm_handle_t *handle, const char *fmt, va_list args);
+int _alpm_run_chroot(alpm_handle_t *handle, const char *path, char *const argv[]);
+int _alpm_ldconfig(alpm_handle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2);
-char *_alpm_filecache_find(const char *filename);
-const char *_alpm_filecache_setup(void);
+char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
+const char *_alpm_filecache_setup(alpm_handle_t *handle);
int _alpm_lstat(const char *path, struct stat *buf);
int _alpm_test_md5sum(const char *filepath, const char *md5sum);
int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b);
-int _alpm_splitname(const char *target, pmpkg_t *pkg);
+int _alpm_splitname(const char *target, char **name, char **version,
+ unsigned long *name_hash);
unsigned long _alpm_hash_sdbm(const char *str);
long _alpm_parsedate(const char *line);
+int _alpm_raw_cmp(const char *first, const char *second);
+int _alpm_raw_ncmp(const char *first, const char *second, size_t max);
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);
@@ -113,6 +129,8 @@ char *strndup(const char *s, size_t n);
#define SYMEXPORT __attribute__((visibility("default")))
#define SYMHIDDEN __attribute__((visibility("internal")))
+#define UNUSED __attribute__((unused))
+
#endif /* _ALPM_UTIL_H */
/* vim: set ts=2 sw=2 noet: */