~ubuntu-branches/ubuntu/feisty/gnupg2/feisty

« back to all changes in this revision

Viewing changes to common/util.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-11-24 18:48:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061124184823-17ir9m46tl09n9k4
Tags: 2.0.0-4ubuntu1
* Synchronize to Debian, reapply remaining Ubuntu changes to pristine Debian
  version:
  - Remove libpcsclite-dev, libopensc2-dev build dependencies (they are in
    universe).

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include <gcrypt.h> /* We need this for the memory function protos. */
26
26
#include <time.h>   /* We need time_t. */
27
 
#include <gpg-error.h> /* we need gpg-error_t. */
 
27
#include <errno.h>  /* We need errno.  */
 
28
#include <gpg-error.h> /* We need gpg_error_t. */
28
29
 
29
30
/* Common GNUlib includes (-I ../gl/). */
30
 
#include "strpbrk.h"
31
 
#include "strsep.h"
32
31
#include "vasprintf.h"
33
32
 
34
33
 
44
43
#include "../jnlib/dotlock.h"
45
44
#include "../jnlib/utf8conv.h"
46
45
 
 
46
#if __GNUC__ >= 4 
 
47
# define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a)))
 
48
#else
 
49
# define GNUPG_GCC_A_SENTINEL(a) 
 
50
#endif
 
51
 
 
52
 
 
53
/* We need this type even if we are not using libreadline and or we
 
54
   did not include libreadline in the current file. */
 
55
#ifndef GNUPG_LIBREADLINE_H_INCLUDED
 
56
typedef char **rl_completion_func_t (const char *, int, int);
 
57
#endif /*!GNUPG_LIBREADLINE_H_INCLUDED*/
 
58
 
 
59
 
47
60
/* Handy malloc macros - please use only them. */
48
61
#define xtrymalloc(a)    gcry_malloc ((a))
49
62
#define xtrymalloc_secure(a)  gcry_malloc_secure ((a))
64
77
#define xmalloc_clear(a) gcry_xcalloc (1, (a))
65
78
#define xmalloc_secure_clear(a) gcry_xcalloc_secure (1, (a))
66
79
 
 
80
/* Convenience function to return a gpg-error code for memory
 
81
   allocation failures.  This function makes sure that an error will
 
82
   be returned even if accidently ERRNO is not set.  */
 
83
static inline gpg_error_t
 
84
out_of_core (void)
 
85
{
 
86
  return gpg_error_from_syserror ();
 
87
}
67
88
 
68
89
/* A type to hold the ISO time.  Note that this this is the same as
69
90
   the the KSBA type ksba_isotime_t. */
70
91
typedef char gnupg_isotime_t[16];
71
92
 
72
93
 
73
 
/*-- maperror.c --*/
74
 
int map_kbx_err (int err);
75
 
gpg_error_t map_assuan_err_with_source (int source, int err);
76
 
int map_to_assuan_status (int rc);
77
 
 
78
94
/*-- gettime.c --*/
79
95
time_t gnupg_get_time (void);
80
96
void   gnupg_get_isotime (gnupg_isotime_t timebuf);
140
156
unsigned char *make_simple_sexp_from_hexstr (const char *line,
141
157
                                             size_t *nscanned);
142
158
 
 
159
/*-- convert.c --*/
 
160
int hex2bin (const char *string, void *buffer, size_t length);
 
161
int hexcolon2bin (const char *string, void *buffer, size_t length);
 
162
char *bin2hex (const void *buffer, size_t length, char *stringbuf);
 
163
char *bin2hexcolon (const void *buffer, size_t length, char *stringbuf);
 
164
 
 
165
 
143
166
/*-- homedir.c --*/
144
167
const char *default_homedir (void);
145
168
 
 
169
/*-- gpgrlhelp.c --*/
 
170
void gnupg_rl_initialize (void);
146
171
 
147
172
/*-- miscellaneous.c --*/
148
173
 
177
202
};
178
203
#endif /* !HAVE_TTYNAME */
179
204
 
180
 
#ifndef HAVE_ISASCII
181
 
static inline int 
182
 
isascii (int c)
183
 
{
184
 
  return (((c) & ~0x7f) == 0);
185
 
}
186
 
#endif /* !HAVE_ISASCII */
187
205
 
188
206
/*-- Macros to replace ctype ones to avoid locale problems. --*/
189
207
#define spacep(p)   (*(p) == ' ' || *(p) == '\t')