A few final changes for the 3.0.6 release
[pacman.git] / lib / libalpm / util.h
blob9f028e8af8f730c0cb1a8e631c534868f66649c0
1 /*
2 * util.h
3 *
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>
9 *
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,
23 * USA.
25 #ifndef _ALPM_UTIL_H
26 #define _ALPM_UTIL_H
28 #include <stdio.h>
29 #if defined(__OpenBSD__)
30 #include "/usr/local/include/archive.h"
31 #include "/usr/local/include/archive_entry.h"
32 #else
33 #include <archive.h>
34 #include <archive_entry.h>
35 #endif
37 #define FREE(p) do { if (p) { free(p); p = NULL; } } while(0)
39 #define ASSERT(cond, action) do { if(!(cond)) { action; } } while(0)
41 #define STRNCPY(s1, s2, len) do { \
42 strncpy(s1, s2, (len)-1); \
43 s1[(len)-1] = 0; \
44 } while(0)
46 #define ARCHIVE_EXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME
48 #ifdef ENABLE_NLS
49 #define _(str) dgettext ("libalpm", str)
50 #else
51 #define _(s) s
52 #endif
54 /*TODO wtf? why is this done like this? */
55 #define SCRIPTLET_START "START "
56 #define SCRIPTLET_DONE "DONE "
58 int _alpm_makepath(const char *path);
59 int _alpm_copyfile(const char *src, const char *dest);
60 char *_alpm_strtoupper(char *str);
61 char *_alpm_strtrim(char *str);
62 int _alpm_lckmk(const char *file);
63 int _alpm_lckrm(const char *file);
64 int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
65 int _alpm_rmrf(const char *path);
66 int _alpm_logaction(unsigned short usesyslog, FILE *f, const char *str);
67 int _alpm_ldconfig(const char *root);
68 #ifdef _ALPM_TRANS_H
69 int _alpm_runscriptlet(const char *root, const char *installfn,
70 const char *script, const char *ver,
71 const char *oldver, pmtrans_t *trans);
72 #ifndef __sun__
73 int _alpm_check_freespace(pmtrans_t *trans, alpm_list_t **data);
74 #endif
75 #endif
76 void _alpm_time2string(time_t t, char *buffer);
77 int _alpm_str_cmp(const void *s1, const void *s2);
79 #ifdef __sun__
80 char* strsep(char** str, const char* delims);
81 char* mkdtemp(char *template);
82 #endif
84 /* check exported library symbols with: nm -C -D <lib> */
85 #define SYMEXPORT __attribute__((visibility("default")))
86 #define SYMHIDDEN __attribute__((visibility("hidden")))
88 #endif /* _ALPM_UTIL_H */
90 /* vim: set ts=2 sw=2 noet: */