Home | History | Annotate | Line # | Download | only in sqlite2mdoc
      1 #ifndef OCONFIGURE_CONFIG_H
      2 #define OCONFIGURE_CONFIG_H
      3 
      4 #ifdef __cplusplus
      5 # error "Do not use C++: this is a C application."
      6 #endif
      7 #if !defined(__GNUC__) || (__GNUC__ < 4)
      8 # define __attribute__(x)
      9 #endif
     10 #if defined(__linux__) || defined(__MINT__) || defined(__wasi__)
     11 # define _GNU_SOURCE /* memmem, memrchr, setresuid... */
     12 # define _DEFAULT_SOURCE /* le32toh, crypt, ... */
     13 #endif
     14 #if defined(__NetBSD__)
     15 # define _OPENBSD_SOURCE /* reallocarray, etc. */
     16 #endif
     17 #if defined(__sun)
     18 # ifndef _XOPEN_SOURCE /* SunOS already defines */
     19 #  define _XOPEN_SOURCE /* XPGx */
     20 # endif
     21 # define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
     22 # ifndef __EXTENSIONS__ /* SunOS already defines */
     23 #  define __EXTENSIONS__ /* reallocarray, etc. */
     24 # endif
     25 #endif
     26 #if !defined(__BEGIN_DECLS)
     27 # define __BEGIN_DECLS
     28 #endif
     29 #if !defined(__END_DECLS)
     30 # define __END_DECLS
     31 #endif
     32 
     33 #include <sys/types.h> /* size_t, mode_t, dev_t */
     34 
     35 #include <stdint.h> /* C99 [u]int[nn]_t types */
     36 
     37 /*
     38  * Results of configuration feature-testing.
     39  */
     40 #define HAVE_ARC4RANDOM 1
     41 #define HAVE_B64_NTOP 1
     42 #define HAVE_CAPSICUM 0
     43 #define HAVE_CRYPT 1
     44 #define HAVE_CRYPT_NEWHASH 0
     45 #define HAVE_ENDIAN_H 1
     46 #define HAVE_ERR 1
     47 #define HAVE_EXPLICIT_BZERO 0
     48 #define HAVE_FTS 1
     49 #define HAVE_GETEXECNAME 0
     50 #define HAVE_GETPROGNAME 1
     51 #define HAVE_INFTIM 1
     52 #define HAVE_LANDLOCK 0
     53 #define HAVE_MD5 1
     54 #define HAVE_MEMMEM 1
     55 #define HAVE_MEMRCHR 1
     56 #define HAVE_MEMSET_S 0
     57 #define HAVE_MKFIFOAT 1
     58 #define HAVE_MKNODAT 1
     59 #define HAVE_OSBYTEORDER_H 0
     60 #define HAVE_PATH_MAX 1
     61 #define HAVE_PLEDGE 0
     62 #define HAVE_PROGRAM_INVOCATION_SHORT_NAME 0
     63 #define HAVE_READPASSPHRASE 0
     64 #define HAVE_REALLOCARRAY 1
     65 #define HAVE_RECALLOCARRAY 0
     66 #define HAVE_SANDBOX_INIT 0
     67 #define HAVE_SCAN_SCALED 0
     68 #define HAVE_SECCOMP_FILTER 0
     69 #define HAVE_SETRESGID 0
     70 #define HAVE_SETRESUID 0
     71 #define HAVE_SHA2 0
     72 #define HAVE_SHA2_H 0
     73 #define HAVE_SOCK_NONBLOCK 1
     74 #define HAVE_STRLCAT 1
     75 #define HAVE_STRLCPY 1
     76 #define HAVE_STRNDUP 1
     77 #define HAVE_STRNLEN 1
     78 #define HAVE_STRTONUM 1
     79 #define HAVE_SYS_BYTEORDER_H 0
     80 #define HAVE_SYS_ENDIAN_H 1
     81 #define HAVE_SYS_MKDEV_H 0
     82 #define HAVE_SYS_QUEUE 1
     83 #define HAVE_SYS_SYSMACROS_H 0
     84 #define HAVE_SYS_TREE 1
     85 #define HAVE_SYSTRACE 0
     86 #define HAVE_UNVEIL 0
     87 #define HAVE_TERMIOS 1
     88 #define HAVE_WAIT_ANY 1
     89 #define HAVE___PROGNAME 1
     90 
     91 /*
     92  * Handle the various major()/minor() header files.
     93  * Use sys/mkdev.h before sys/sysmacros.h because SunOS
     94  * has both, where only the former works properly.
     95  */
     96 #if HAVE_SYS_MKDEV_H
     97 # define COMPAT_MAJOR_MINOR_H <sys/mkdev.h>
     98 #elif HAVE_SYS_SYSMACROS_H
     99 # define COMPAT_MAJOR_MINOR_H <sys/sysmacros.h>
    100 #else
    101 # define COMPAT_MAJOR_MINOR_H <sys/types.h>
    102 #endif
    103 
    104 /*
    105  * Make it easier to include endian.h forms.
    106  */
    107 #if HAVE_ENDIAN_H
    108 # define COMPAT_ENDIAN_H <endian.h>
    109 #elif HAVE_SYS_ENDIAN_H
    110 # define COMPAT_ENDIAN_H <sys/endian.h>
    111 #elif HAVE_OSBYTEORDER_H
    112 # define COMPAT_ENDIAN_H <libkern/OSByteOrder.h>
    113 #elif HAVE_SYS_BYTEORDER_H
    114 # define COMPAT_ENDIAN_H <sys/byteorder.h>
    115 #else
    116 # warning No suitable endian.h could be found.
    117 # warning Please e-mail the maintainers with your OS.
    118 # define COMPAT_ENDIAN_H <endian.h>
    119 #endif
    120 
    121 /*
    122  * Compatibility for sha2(3).
    123  */
    124 
    125 /*** SHA-256/384/512 Various Length Definitions ***********************/
    126 #define SHA256_BLOCK_LENGTH		64
    127 #define SHA256_DIGEST_LENGTH		32
    128 #define SHA256_DIGEST_STRING_LENGTH	(SHA256_DIGEST_LENGTH * 2 + 1)
    129 #define SHA384_BLOCK_LENGTH		128
    130 #define SHA384_DIGEST_LENGTH		48
    131 #define SHA384_DIGEST_STRING_LENGTH	(SHA384_DIGEST_LENGTH * 2 + 1)
    132 #define SHA512_BLOCK_LENGTH		128
    133 #define SHA512_DIGEST_LENGTH		64
    134 #define SHA512_DIGEST_STRING_LENGTH	(SHA512_DIGEST_LENGTH * 2 + 1)
    135 #define SHA512_256_BLOCK_LENGTH		128
    136 #define SHA512_256_DIGEST_LENGTH	32
    137 #define SHA512_256_DIGEST_STRING_LENGTH	(SHA512_256_DIGEST_LENGTH * 2 + 1)
    138 
    139 /*** SHA-224/256/384/512 Context Structure *******************************/
    140 typedef struct _SHA2_CTX {
    141 	union {
    142 		uint32_t	st32[8];
    143 		uint64_t	st64[8];
    144 	} state;
    145 	uint64_t	bitcount[2];
    146 	uint8_t		buffer[SHA512_BLOCK_LENGTH];
    147 } SHA2_CTX;
    148 
    149 void SHA256Init(SHA2_CTX *);
    150 void SHA256Transform(uint32_t state[8], const uint8_t [SHA256_BLOCK_LENGTH]);
    151 void SHA256Update(SHA2_CTX *, const uint8_t *, size_t);
    152 void SHA256Pad(SHA2_CTX *);
    153 void SHA256Final(uint8_t [SHA256_DIGEST_LENGTH], SHA2_CTX *);
    154 char *SHA256End(SHA2_CTX *, char *);
    155 char *SHA256File(const char *, char *);
    156 char *SHA256FileChunk(const char *, char *, off_t, off_t);
    157 char *SHA256Data(const uint8_t *, size_t, char *);
    158 
    159 void SHA384Init(SHA2_CTX *);
    160 void SHA384Transform(uint64_t state[8], const uint8_t [SHA384_BLOCK_LENGTH]);
    161 void SHA384Update(SHA2_CTX *, const uint8_t *, size_t);
    162 void SHA384Pad(SHA2_CTX *);
    163 void SHA384Final(uint8_t [SHA384_DIGEST_LENGTH], SHA2_CTX *);
    164 char *SHA384End(SHA2_CTX *, char *);
    165 char *SHA384File(const char *, char *);
    166 char *SHA384FileChunk(const char *, char *, off_t, off_t);
    167 char *SHA384Data(const uint8_t *, size_t, char *);
    168 
    169 void SHA512Init(SHA2_CTX *);
    170 void SHA512Transform(uint64_t state[8], const uint8_t [SHA512_BLOCK_LENGTH]);
    171 void SHA512Update(SHA2_CTX *, const uint8_t *, size_t);
    172 void SHA512Pad(SHA2_CTX *);
    173 void SHA512Final(uint8_t [SHA512_DIGEST_LENGTH], SHA2_CTX *);
    174 char *SHA512End(SHA2_CTX *, char *);
    175 char *SHA512File(const char *, char *);
    176 char *SHA512FileChunk(const char *, char *, off_t, off_t);
    177 char *SHA512Data(const uint8_t *, size_t, char *);
    178 
    179 #define	FMT_SCALED_STRSIZE	7 /* minus sign, 4 digits, suffix, null byte */
    180 int	fmt_scaled(long long, char *);
    181 int	scan_scaled(char *, long long *);
    182 /*
    183  * Compatibility for explicit_bzero(3).
    184  */
    185 extern void explicit_bzero(void *, size_t);
    186 
    187 /*
    188  * Macros and function required for readpassphrase(3).
    189  */
    190 #define RPP_ECHO_OFF 0x00
    191 #define RPP_ECHO_ON 0x01
    192 #define RPP_REQUIRE_TTY 0x02
    193 #define RPP_FORCELOWER 0x04
    194 #define RPP_FORCEUPPER 0x08
    195 #define RPP_SEVENBIT 0x10
    196 #define RPP_STDIN 0x20
    197 char *readpassphrase(const char *, char *, size_t, int);
    198 
    199 /*
    200  * Compatibility for recallocarray(3).
    201  */
    202 extern void *recallocarray(void *, size_t, size_t, size_t);
    203 
    204 /*
    205  * Compatibility for setresgid(2).
    206  */
    207 int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
    208 
    209 /*
    210  * Compatibility for setresuid(2).
    211  */
    212 int setresuid(uid_t ruid, uid_t euid, uid_t suid);
    213 
    214 #endif /*!OCONFIGURE_CONFIG_H*/
    215