merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

platform.h (6890B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014, 2015, 2016, 2021 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13   You should have received a copy of the GNU General Public License along with
     14   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 
     17 /**
     18  * @file src/include/platform.h
     19  * @brief This file contains the includes and definitions which are used by the
     20  *        rest of the modules
     21  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
     22  */
     23 
     24 #ifndef PLATFORM_H_
     25 #define PLATFORM_H_
     26 
     27 /* Include our configuration header */
     28 #ifndef HAVE_USED_CONFIG_H
     29 #define HAVE_USED_CONFIG_H
     30 #ifdef HAVE_CONFIG_H
     31 #include "taler_merchant_config.h"
     32 #endif
     33 #endif
     34 
     35 
     36 #if (GNUNET_EXTRA_LOGGING >= 1)
     37 #define VERBOSE(cmd) cmd
     38 #else
     39 #define VERBOSE(cmd) do { break; } while (0)
     40 #endif
     41 
     42 /* Include the features available for GNU source */
     43 #define _GNU_SOURCE
     44 
     45 
     46 #ifdef HAVE_SYS_TYPES_H
     47 #include <sys/types.h>
     48 #endif
     49 
     50 #ifdef __clang__
     51 #undef HAVE_STATIC_ASSERT
     52 #endif
     53 
     54 /**
     55  * These may be expensive, but good for debugging...
     56  */
     57 #define ALLOW_EXTRA_CHECKS GNUNET_YES
     58 
     59 /**
     60  * For strptime (glibc2 needs this).
     61  */
     62 #ifndef _XOPEN_SOURCE
     63 #define _XOPEN_SOURCE 499
     64 #endif
     65 
     66 #ifndef _REENTRANT
     67 #define _REENTRANT
     68 #endif
     69 
     70 /* configuration options */
     71 
     72 #define VERBOSE_STATS 0
     73 
     74 #include <netdb.h>
     75 #include <sys/socket.h>
     76 #include <sys/un.h>
     77 #if HAVE_NETINET_IN_H
     78 #include <netinet/in.h>
     79 #endif
     80 #if HAVE_NETINET_IN_SYSTM_H
     81 #include <netinet/in_systm.h>
     82 #endif
     83 #if HAVE_NETINET_IP_H
     84 #include <netinet/ip.h>         /* superset of previous */
     85 #endif
     86 #include <arpa/inet.h>
     87 #include <netinet/tcp.h>
     88 #include <pwd.h>
     89 #include <sys/ioctl.h>
     90 #include <sys/wait.h>
     91 #include <grp.h>
     92 
     93 #include <string.h>
     94 #include <stdio.h>
     95 #include <stdlib.h>
     96 #include <stdint.h>
     97 #include <stdarg.h>
     98 #include <stdbool.h>
     99 #include <errno.h>
    100 #include <signal.h>
    101 #include <libgen.h>
    102 #ifdef HAVE_MALLOC_H
    103 #include <malloc.h>             /* for mallinfo on GNU */
    104 #endif
    105 #include <unistd.h>             /* KLB_FIX */
    106 #include <sys/stat.h>
    107 #include <sys/types.h>
    108 #include <dirent.h>             /* KLB_FIX */
    109 #include <fcntl.h>
    110 #include <math.h>
    111 #if HAVE_SYS_PARAM_H
    112 #include <sys/param.h>
    113 #endif
    114 #if HAVE_SYS_TIME_H
    115 #include <sys/time.h>
    116 #endif
    117 #include <time.h>
    118 #ifdef BSD
    119 #include <net/if.h>
    120 #endif
    121 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
    122 #include <semaphore.h>
    123 #endif
    124 #ifdef DARWIN
    125 #include <dlfcn.h>
    126 #include <semaphore.h>
    127 #include <net/if.h>
    128 #endif
    129 #if defined(__linux__) || defined(GNU)
    130 #include <net/if.h>
    131 #endif
    132 #ifdef SOLARIS
    133 #include <sys/sockio.h>
    134 #include <sys/filio.h>
    135 #include <sys/loadavg.h>
    136 #include <semaphore.h>
    137 #endif
    138 #if HAVE_UCRED_H
    139 #include <ucred.h>
    140 #endif
    141 #if HAVE_SYS_UCRED_H
    142 #include <sys/ucred.h>
    143 #endif
    144 #if HAVE_IFADDRS_H
    145 #include <ifaddrs.h>
    146 #endif
    147 #include <errno.h>
    148 #include <limits.h>
    149 
    150 #if HAVE_VFORK_H
    151 #include <vfork.h>
    152 #endif
    153 
    154 #include <ctype.h>
    155 #if HAVE_SYS_RESOURCE_H
    156 #include <sys/resource.h>
    157 #endif
    158 
    159 #if HAVE_ENDIAN_H
    160 #include <endian.h>
    161 #endif
    162 #if HAVE_SYS_ENDIAN_H
    163 #include <sys/endian.h>
    164 #endif
    165 
    166 #define DIR_SEPARATOR '/'
    167 #define DIR_SEPARATOR_STR "/"
    168 #define PATH_SEPARATOR ':'
    169 #define PATH_SEPARATOR_STR ":"
    170 #define NEWLINE "\n"
    171 
    172 #include <locale.h>
    173 #include "gettext.h"
    174 /**
    175  * GNU gettext support macro.
    176  */
    177 #define _(String) dgettext (PACKAGE, String)
    178 #define LIBEXTRACTOR_GETTEXT_DOMAIN "libextractor"
    179 
    180 #include <sys/mman.h>
    181 
    182 /* FreeBSD_kernel is not defined on the now discontinued kFreeBSD  */
    183 #if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__)
    184 #define __BYTE_ORDER BYTE_ORDER
    185 #define __BIG_ENDIAN BIG_ENDIAN
    186 #endif
    187 
    188 #ifdef DARWIN
    189 #define __BYTE_ORDER BYTE_ORDER
    190 #define __BIG_ENDIAN BIG_ENDIAN
    191 /* not available on darwin, override configure */
    192 #undef HAVE_STAT64
    193 #undef HAVE_MREMAP
    194 #endif
    195 
    196 #if ! HAVE_ATOLL
    197 long long
    198 atoll (const char *nptr);
    199 
    200 #endif
    201 
    202 #if ENABLE_NLS
    203 #include "langinfo.h"
    204 #endif
    205 
    206 #ifndef SIZE_MAX
    207 #define SIZE_MAX ((size_t) (-1))
    208 #endif
    209 
    210 #ifndef O_LARGEFILE
    211 #define O_LARGEFILE 0
    212 #endif
    213 
    214 /**
    215  * AI_NUMERICSERV not defined in windows.  Then we just do without.
    216  */
    217 #ifndef AI_NUMERICSERV
    218 #define AI_NUMERICSERV 0
    219 #endif
    220 
    221 
    222 #if defined(__sparc__)
    223 #define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \
    224                                                                  sizeof((val))); \
    225                                __tmp; })
    226 #else
    227 #define MAKE_UNALIGNED(val) val
    228 #endif
    229 
    230 /**
    231  * The termination signal
    232  */
    233 #define GNUNET_TERM_SIG SIGTERM
    234 
    235 
    236 #ifndef PATH_MAX
    237 /**
    238  * Assumed maximum path length.
    239  */
    240 #define PATH_MAX 4096
    241 #endif
    242 
    243 #if HAVE_THREAD_LOCAL_GCC
    244 #define TALER_THREAD_LOCAL __thread
    245 #else
    246 #define TALER_THREAD_LOCAL
    247 #endif
    248 
    249 
    250 /**
    251  * clang et al do not have such an attribute
    252  */
    253 #if __has_attribute (__nonstring__)
    254 # define __nonstring                    __attribute__((__nonstring__))
    255 #else
    256 # define __nonstring
    257 #endif
    258 
    259 /* Do not use shortcuts for gcrypt mpi */
    260 #define GCRYPT_NO_MPI_MACROS 1
    261 
    262 /* Do not use deprecated functions from gcrypt */
    263 #define GCRYPT_NO_DEPRECATED 1
    264 
    265 /* Ignore MHD deprecations for now as we want to be compatible
    266    to "ancient" MHD releases. */
    267 #define MHD_NO_DEPRECATION 1
    268 
    269 
    270 /**
    271  * Required prefix for the authorization header as per RFC 8959.
    272  * (Follows RFC 6750 albeit technically violates RFC 7235, but
    273  *  Mark Nottingham thinks this should be fixed by revising HTTP
    274  *  spec (https://github.com/httpwg/http-core/issues/733))
    275  */
    276 #define RFC_8959_PREFIX "secret-token:"
    277 
    278 /* LSB-style exit status codes */
    279 #ifndef EXIT_INVALIDARGUMENT
    280 /**
    281  * Command-line arguments are invalid.
    282  * Restarting useless.
    283  */
    284 #define EXIT_INVALIDARGUMENT 2
    285 #endif
    286 
    287 #ifndef EXIT_NOTIMPLEMENTED
    288 /**
    289  * The requested operation is not implemented.
    290  * Restarting useless.
    291  */
    292 #define EXIT_NOTIMPLEMENTED 3
    293 #endif
    294 
    295 #ifndef EXIT_NOPERMISSION
    296 /**
    297  * Permissions needed to run are not available.
    298  * Restarting useless.
    299  */
    300 #define EXIT_NOPERMISSION 4
    301 #endif
    302 
    303 #ifndef EXIT_NOTINSTALLED
    304 /**
    305  * Key resources are not installed.
    306  * Restarting useless.
    307  */
    308 #define EXIT_NOTINSTALLED 5
    309 #endif
    310 
    311 #ifndef EXIT_NOTCONFIGURED
    312 /**
    313  * Key configuration settings are missing or invalid.
    314  * Restarting useless.
    315  */
    316 #define EXIT_NOTCONFIGURED 6
    317 #endif
    318 
    319 #ifndef EXIT_NOTRUNNING
    320 #define EXIT_NOTRUNNING 7
    321 #endif
    322 
    323 #ifndef EXIT_NO_RESTART
    324 /**
    325  * Exit code from 'main' if we do not want to be restarted,
    326  * except by manual intervention (hard failure).
    327  */
    328 #define EXIT_NO_RESTART 9
    329 #endif
    330 
    331 
    332 #endif  /* PLATFORM_H_ */
    333 
    334 /* end of platform.h */