2 *****************************************************************************
6 * Author: Damien S. Stuart
8 * Purpose: Common header for libfko source files.
10 * Copyright 2009-2010 Damien Stuart (dstuart@dstuart.org)
12 * License (GNU Public License):
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 *****************************************************************************
32 #define FKO_COMMON_H 1
39 #include <sys/types.h>
46 #endif /*STDC_HEADERS*/
53 #include <ctype.h> /* Using this for isdigit() */
55 /* Fall-back does not account for locale */
56 #define isdigit(c) (c >= 48 && c <= 57)
60 /* These are needed for the digest code under windows.
62 typedef unsigned __int8 uint8_t;
63 typedef unsigned __int32 uint32_t;
64 typedef unsigned __int64 uint64_t;
66 #define strdup _strdup
73 /* Work out endianess (sp?)
75 #if HAVE_ENDIAN_H /* Should cover most Linux systems */
77 #define BYTEORDER __BYTE_ORDER
78 #elif HAVE_SYS_ENDIAN_H /* FreeBSD has a sys/endian.h */
79 #include <sys/endian.h>
80 #define BYTEORDER _BYTE_ORDER
81 #elif HAVE_SYS_BYTEORDER_H /* Solaris (v10 at least) seems to have this */
82 #include <sys/byteorder.h>
83 #if defined(_BIG_ENDIAN)
84 #define BYTEORDER 4321
85 #elif defined(_LITTLE_ENDIAN)
86 #define BYTEORDER 1234
88 #error unable to determine BYTEORDER
95 #ifdef HAVE_SYS_TIME_H
97 #ifdef TIME_WITH_SYS_TIME
103 /* Convenient macros for wrapping sections in 'extern "C" {' constructs.
106 #define BEGIN_C_DECLS extern "C" {
107 #define END_C_DECLS }
108 #else /* !__cplusplus */
109 #define BEGIN_C_DECLS
111 #endif /* __cplusplus */
113 /* Pull in gpgme.h if we have it.
119 #include "fko_util.h"
120 #include "fko_limits.h"
121 #include "fko_state.h"
122 #include "fko_context.h"
124 /* Try to cover for those that do not have bzero.
126 #if !HAVE_BZERO && HAVE_MEMSET
127 # define bzero(buf, bytes) ((void) memset (buf, 0, bytes))
130 #endif /* FKO_COMMON_H */