merchant

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

platform.h (6999B)


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