Debian Codegraph @

src/util/util.h

raw symbols SCIP
1 /* util.h - Utility functions for GnuPG
2 * Copyright (C) 2001, 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
3 *
4 * This file is part of GnuPG.
5 *
6 * GnuPG 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 * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 * USA.
20 */
21
22 #ifndef GNUPG_COMMON_UTIL_H
23 #define GNUPG_COMMON_UTIL_H
24
25 #include <gcrypt.h> /* We need this for the memory function protos. */
26 #include <time.h> /* We need time_t. */
27 #include <errno.h> /* We need errno. */
28 #include <gpg-error.h> /* We need gpg_error_t. */
29 #include <stdio.h>
30
31 /* Get all the stuff from jnlib. */
32 //#include "../jnlib/logging.h"
33 //#include "../jnlib/argparse.h"
34 //#include "../jnlib/stringhelp.h"
35 //#include "../jnlib/mischelp.h"
36 //#include "../jnlib/strlist.h"
37 //#include "../jnlib/utf8conv.h"
38
39 #define DIM(v) (sizeof(v)/sizeof((v)[0]))
40 #define DIMof(type,member) DIM(((type *)0)->member)
41
42 /*-- convert.c --*/
43 char *bin2hex (const void *buffer, size_t length, char *stringbuf);
44
45 /*-- Macros to replace ctype ones to avoid locale problems. --*/
46 #define spacep(p) (*(p) == ' ' || *(p) == '\t')
47 #define digitp(p) (*(p) >= '0' && *(p) <= '9')
48 #define hexdigitp(a) (digitp (a) \
49 || (*(a) >= 'A' && *(a) <= 'F') \
50 || (*(a) >= 'a' && *(a) <= 'f'))
51 /* Note this isn't identical to a C locale isspace() without \f and
52 \v, but works for the purposes used here. */
53 #define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')
54
55 /* The atoi macros assume that the buffer has only valid digits. */
56 #define atoi_1(p) (*(p) - '0' )
57 #define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
58 #define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
59 #define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
60 *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
61 #define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
62 #define xtoi_4(p) ((xtoi_2(p) * 256) + xtoi_2((p)+2))
63
64
65
66 #endif /*GNUPG_COMMON_UTIL_H*/