/[winpt]/trunk/MyGPGME/util.h
ViewVC logotype

Annotation of /trunk/MyGPGME/util.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations)
Mon Jan 31 11:02:21 2005 UTC (20 years, 1 month ago) by twoaday
File MIME type: text/plain
File size: 5104 byte(s)
WinPT initial checkin.


1 twoaday 2 /* util.h
2     * Copyright (C) 2000 Werner Koch (dd9jn)
3     * Copyright (C) 2000-2004 Timo Schulz
4     *
5     * This file is part of MyGPGME.
6     *
7     * MyGPGME is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * MyGPGME is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20     */
21    
22     #ifndef GPGME_UTIL_H
23     #define GPGME_UTIL_H
24    
25     #include <windows.h>
26     #include <malloc.h>
27    
28     #include "types.h"
29    
30     #ifndef safe_free
31     #define safe_free(a) do { if (a) { free (a); a = NULL; } } while (0)
32     #endif
33    
34     #define mk_error(a) (GPGME_##a)
35    
36     #ifndef DIM
37     #define DIM(v) (sizeof (v)/sizeof ((v)[0]))
38     #endif
39     #define DIMof(type,member) DIM(((type *)0)->member)
40     #ifndef STR
41     #define STR(v) #v
42     #endif
43     #define STR2(v) STR(v)
44    
45    
46     void _gpgme_debug (int level, int line, const char *fname,
47     const char *format, ... );
48     void _gpgme_debug_begin ( void **helper, int level, const char *text);
49     int _gpgme_debug_enabled ( void **helper );
50     void _gpgme_debug_add (void **helper, const char *format, ...);
51     void _gpgme_debug_end (void **helper, const char *text);
52    
53     #define _debug _gpgme_debug
54    
55     #define DEBUG0(x) _debug (1, __LINE__, __FILE__, x )
56     #define DEBUG1(x,a) _debug (1, __LINE__, __FILE__, x, (a) )
57     #define DEBUG2(x,a,b) _debug (1, __LINE__, __FILE__, x, (a), (b) )
58     #define DEBUG3(x,a,b,c) _debug (1, __LINE__, __FILE__, x, (a), (b), (c) )
59     #define DEBUG4(x,a,b,c,d) _debug (1, __LINE__, __FILE__, x, (a), (b), (c),\
60     (d) )
61     #define DEBUG5(x,a,b,c,d,e) _debug (1, __LINE__, __FILE__, x, (a), (b), \
62     (c), (d), (e) )
63     #define DEBUG6(x,a,b,c,d,e,f) _debug (1, __LINE__, __FILE__, x, (a), (b), \
64     (c), (d), (e), (f) )
65     #define DEBUG7(x,a,b,c,d,e,f,g) _debug (1, __LINE__, __FILE__, x, (a), \
66     (b), (c), (d), (e), (f), (g) )
67     #define DEBUG8(x,a,b,c,d,e,f,g,h) _debug (1, __LINE__, __FILE__ x, (a), (b), \
68     (c), (d), (e), (f), (g), (h) )
69     #define DEBUG9(x,a,b,c,d,e,f,g,h,i) _debug (1, __LINE__, __FILE__ x, (a), (b), \
70     (c), (d), (e), (f), (g), (h), (i) )
71     #define DEBUG10(x,a,b,c,d,e,f,g,h,i,j) _debug (1, __LINE__, __FILE__, x, (a), \
72     (b), (c), (d), (e), (f), (g), (h), (i), (j) )
73    
74     #define DEBUG_BEGIN(y,x) _gpgme_debug_begin (&(y), 1, __FILE__ ":" \
75     STR2 (__LINE__) ": " x )
76     #define DEBUG_ENABLED(y) _gpgme_debug_enabled(&(y))
77     #define DEBUG_ADD0(y,x) _gpgme_debug_add (&(y), (x), \
78     )
79     #define DEBUG_ADD1(y,x,a) _gpgme_debug_add (&(y), (x), \
80     (a) )
81     #define DEBUG_ADD2(y,x,a,b) _gpgme_debug_add (&(y), (x), \
82     (a), (b) )
83     #define DEBUG_ADD3(y,x,a,b,c) _gpgme_debug_add (&(y), (x), \
84     (a), (b), (c) )
85     #define DEBUG_ADD4(y,x,a,b,c,d) _gpgme_debug_add (&(y), (x), \
86     (a), (b), (c), (d) )
87     #define DEBUG_ADD5(y,x,a,b,c,d,e) _gpgme_debug_add (&(y), (x), \
88     (a), (b), (c), (d), (e) )
89     #define DEBUG_END(y,x) _gpgme_debug_end (&(y), (x) )
90    
91     #ifndef HAVE_STPCPY
92     char *stpcpy (char *a, const char *b);
93     #endif
94    
95     #ifndef HAVE_STRSEP
96     char * strsep (char **stringp, const char *delim);
97     #endif
98    
99     #ifndef HAVE_MEMISTR
100     const char *memistr( const char *buf, size_t buflen, const char *sub );
101     #endif
102    
103     #define return_if_fail(expr) do { \
104     if (!(expr)) { \
105     fprintf (stderr, "%s:%d: assertion `%s' failed", \
106     __FILE__, __LINE__, #expr ); \
107     return; \
108     } } while (0)
109     #define return_null_if_fail(expr) do { \
110     if (!(expr)) { \
111     fprintf (stderr, "%s:%d: assertion `%s' failed", \
112     __FILE__, __LINE__, #expr ); \
113     return NULL; \
114     } } while (0)
115     #define return_val_if_fail(expr,val) do { \
116     if (!(expr)) { \
117     fprintf (stderr, "%s:%d: assertion `%s' failed", \
118     __FILE__, __LINE__, #expr ); \
119     return (val); \
120     } } while (0)
121    
122    
123     FILE * my_fopen (const char * fname, const char * mode);
124     /*-- {posix,w32}-util.c --*/
125     const char *_gpgme_get_gpg_path (void);
126     char * _gpgme_get_gpg_optfile(void);
127     const char * _gpgme_get_gpg_keyring( const char *keyring );
128    
129     #endif /* GPGME_UTIL_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26