summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/util.h')
-rw-r--r--lib/libalpm/util.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 26fa9044..d5cf0127 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -24,8 +24,6 @@
#ifndef _ALPM_UTIL_H
#define _ALPM_UTIL_H
-#include "config.h"
-
#include "alpm_list.h"
#include "alpm.h"
#include "package.h" /* alpm_pkg_t */
@@ -35,11 +33,13 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h> /* size_t */
-#include <time.h>
+#include <sys/types.h>
#include <sys/stat.h> /* struct stat */
-#include <archive.h> /* struct archive */
#include <math.h> /* fabs */
#include <float.h> /* DBL_EPSILON */
+#include <fcntl.h> /* open, close */
+
+#include <archive.h> /* struct archive */
#ifdef ENABLE_NLS
#include <libintl.h> /* here so it doesn't need to be included elsewhere */
@@ -51,8 +51,8 @@
#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)
+#define MALLOC(p, s, action) do { p = malloc(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(l * s); action; } } while(0)
/* This strdup macro is NULL safe- copying NULL will yield NULL */
#define STRDUP(r, s, action) do { if(s != NULL) { r = strdup(s); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0)
#define STRNDUP(r, s, l, action) do { if(s != NULL) { r = strndup(s, l); if(r == NULL) { ALLOC_FAIL(strlen(s)); action; } } else { r = NULL; } } while(0)
@@ -82,6 +82,13 @@
#define ALPM_BUFFER_SIZE 8192
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#define OPEN(fd, path, flags) do { fd = open(path, flags | O_BINARY); } while(fd == -1 && errno == EINTR)
+#define CLOSE(fd) do { int ret; do { ret = close(fd); } while(ret == -1 && errno == EINTR); } while(0)
+
/**
* Used as a buffer/state holder for _alpm_archive_fgets().
*/
@@ -106,16 +113,18 @@ enum _alpm_csum {
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);
size_t _alpm_strip_newline(char *str);
+
+int _alpm_open_archive(alpm_handle_t *handle, const char *path,
+ struct stat *buf, struct archive **archive, alpm_errno_t error);
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);
+
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_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]);
int _alpm_ldconfig(alpm_handle_t *handle);
int _alpm_str_cmp(const void *s1, const void *s2);
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
@@ -127,10 +136,11 @@ int _alpm_splitname(const char *target, char **name, char **version,
unsigned long *name_hash);
unsigned long _alpm_hash_sdbm(const char *str);
off_t _alpm_strtoofft(const char *line);
-time_t _alpm_parsedate(const char *line);
+alpm_time_t _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);
int _alpm_access(alpm_handle_t *handle, const char *dir, const char *file, int amode);
+int _alpm_fnmatch(const void *pattern, const void *string);
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);