More changes and and some new functions
[gpgme.git] / gpgme / util.h
1 /* util.h 
2  *      Copyright (C) 2000 Werner Koch (dd9jn)
3  *
4  * This file is part of GPGME.
5  *
6  * GPGME is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * GPGME is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19  */
20
21 #ifndef UTIL_H
22 #define UTIL_H
23
24 #include "types.h"
25
26 void *_gpgme_malloc (size_t n );
27 void *_gpgme_calloc (size_t n, size_t m );
28 void *_gpgme_realloc (void *p, size_t n);
29 char *_gpgme_strdup (const char *p);
30 void  _gpgme_free ( void *a );
31
32 #define xtrymalloc(a)    _gpgme_malloc((a))
33 #define xtrycalloc(a,b)  _gpgme_calloc((a),(b))
34 #define xtryrealloc(a,b) _gpgme_realloc((a),(b))
35 #define xtrystrdup(a)    _gpgme_strdup((a))
36 #define xfree(a)         _gpgme_free((a))
37
38
39 #define mk_error(a) ( GPGME_##a )
40
41 #define DIM(v) (sizeof(v)/sizeof((v)[0]))
42 #define DIMof(type,member)   DIM(((type *)0)->member)
43
44
45
46 #ifndef HAVE_STPCPY
47 char *stpcpy (char *a, const char *b);
48 #endif
49
50
51
52 #endif /* UTIL_H */
53
54
55
56