"Fossies" - the Fresh Open Source Software Archive

Member "gnuastro-0.9/lib/gnuastro/type.h" (6 Mar 2019, 5602 Bytes) of package /linux/privat/gnuastro-0.9.tar.lz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "type.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.8_vs_0.9.

    1 /*********************************************************************
    2 Type -- Type information and basic operations.
    3 This is part of GNU Astronomy Utilities (Gnuastro) package.
    4 
    5 Original author:
    6      Mohammad Akhlaghi <mohammad@akhlaghi.org>
    7 Contributing author(s):
    8 Copyright (C) 2015-2019, Free Software Foundation, Inc.
    9 
   10 Gnuastro is free software: you can redistribute it and/or modify it
   11 under the terms of the GNU General Public License as published by the
   12 Free Software Foundation, either version 3 of the License, or (at your
   13 option) any later version.
   14 
   15 Gnuastro is distributed in the hope that it will be useful, but
   16 WITHOUT ANY WARRANTY; without even the implied warranty of
   17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18 General Public License for more details.
   19 
   20 You should have received a copy of the GNU General Public License
   21 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
   22 **********************************************************************/
   23 #ifndef __GAL_TYPE_H__
   24 #define __GAL_TYPE_H__
   25 
   26 #include <limits.h>
   27 #include <stdint.h>
   28 
   29 #include <gsl/gsl_complex.h>
   30 
   31 /* When we are within Gnuastro's building process, `IN_GNUASTRO_BUILD' is
   32    defined. In the build process, installation information (in particular
   33    `GAL_CONFIG_SIZEOF_SIZE_T' that we need below) is kept in
   34    `config.h'. When building a user's programs, this information is kept in
   35    `gnuastro/config.h'. Note that all `.c' files in Gnuastro's source must
   36    start with the inclusion of `config.h' and that `gnuastro/config.h' is
   37    only created at installation time (not present during the building of
   38    Gnuastro). */
   39 #ifndef IN_GNUASTRO_BUILD
   40 #include <gnuastro/config.h>
   41 #endif
   42 
   43 
   44 
   45 /* C++ Preparations */
   46 #undef __BEGIN_C_DECLS
   47 #undef __END_C_DECLS
   48 #ifdef __cplusplus
   49 # define __BEGIN_C_DECLS extern "C" {
   50 # define __END_C_DECLS }
   51 #else
   52 # define __BEGIN_C_DECLS                /* empty */
   53 # define __END_C_DECLS                  /* empty */
   54 #endif
   55 /* End of C++ preparations */
   56 
   57 
   58 
   59 /* Actual header contants (the above were for the Pre-processor). */
   60 __BEGIN_C_DECLS  /* From C++ preparations */
   61 
   62 
   63 
   64 
   65 
   66 /*************************************************************
   67  **************           Constants            ***************
   68  *************************************************************/
   69 /* Macros to identify the type of data. */
   70 enum gal_types
   71 {
   72   GAL_TYPE_INVALID,         /* Invalid (=0 by C standard).             */
   73 
   74   GAL_TYPE_BIT,             /* 1 bit                                   */
   75   GAL_TYPE_UINT8,           /* 8-bit  unsigned integer.                */
   76   GAL_TYPE_INT8,            /* 8-bit  signed   integer.                */
   77   GAL_TYPE_UINT16,          /* 16-bit unsigned integer.                */
   78   GAL_TYPE_INT16,           /* 16-bit signed   integer.                */
   79   GAL_TYPE_UINT32,          /* 32-bit unsigned integer.                */
   80   GAL_TYPE_INT32,           /* 32-bit signed   integer.                */
   81   GAL_TYPE_UINT64,          /* 64-bit unsigned integer.                */
   82   GAL_TYPE_INT64,           /* 64-bit signed   integer.                */
   83   GAL_TYPE_FLOAT32,         /* 32-bit single precision floating point. */
   84   GAL_TYPE_FLOAT64,         /* 64-bit double precision floating point. */
   85   GAL_TYPE_COMPLEX32,       /* Complex 32-bit floating point.          */
   86   GAL_TYPE_COMPLEX64,       /* Complex 64-bit floating point.          */
   87   GAL_TYPE_STRING,          /* String of characters.                   */
   88   GAL_TYPE_STRLL,           /* Linked list of strings.                 */
   89 };
   90 
   91 
   92 
   93 /* Define system specific types. For example `size_t' is 4 and 8 bytes on
   94    32 and 64 bit systems respectively. In both cases, the standard defines
   95    `size_t' to be unsigned. A similar case exists for `long', but it is
   96    signed. During `./configure' the sizeof `size_t' and `long' were found
   97    and are used to define an alias for these system specific types.
   98 
   99    Note: we are not using `else'. This is done because by any chance, if
  100    the length of these types is not what is expected (4 or 8), then the
  101    aliases are not defined and the compiler will crash. */
  102 #if GAL_CONFIG_SIZEOF_SIZE_T == 4
  103 #define GAL_TYPE_SIZE_T GAL_TYPE_UINT32
  104 #elif GAL_CONFIG_SIZEOF_SIZE_T == 8
  105 #define GAL_TYPE_SIZE_T GAL_TYPE_UINT64
  106 #endif
  107 
  108 #if GAL_CONFIG_SIZEOF_LONG == 4
  109 #define GAL_TYPE_LONG  GAL_TYPE_INT32
  110 #define GAL_TYPE_ULONG GAL_TYPE_UINT32
  111 #elif GAL_CONFIG_SIZEOF_LONG == 8
  112 #define GAL_TYPE_LONG  GAL_TYPE_INT64
  113 #define GAL_TYPE_ULONG GAL_TYPE_UINT64
  114 #endif
  115 
  116 
  117 
  118 
  119 
  120 
  121 
  122 /*************************************************************
  123  **************         General info           ***************
  124  *************************************************************/
  125 size_t
  126 gal_type_sizeof(uint8_t type);
  127 
  128 char *
  129 gal_type_name(uint8_t type, int long_name);
  130 
  131 uint8_t
  132 gal_type_from_name(char *str);
  133 
  134 void
  135 gal_type_min(uint8_t type, void *in);
  136 
  137 void
  138 gal_type_max(uint8_t type, void *in);
  139 
  140 int
  141 gal_type_is_int(uint8_t type);
  142 
  143 int
  144 gal_type_is_list(uint8_t type);
  145 
  146 int
  147 gal_type_out(int first_type, int second_type);
  148 
  149 
  150 
  151 
  152 
  153 /*************************************************************
  154  **************         To/from string         ***************
  155  *************************************************************/
  156 
  157 char *
  158 gal_type_bit_string(void *in, size_t size);
  159 
  160 char *
  161 gal_type_to_string(void *ptr, uint8_t type, int quote_if_str_has_space);
  162 
  163 int
  164 gal_type_from_string(void **out, char *string, uint8_t type);
  165 
  166 void *
  167 gal_type_string_to_number(char *string, uint8_t *type);
  168 
  169 
  170 
  171 
  172 
  173 __END_C_DECLS    /* From C++ preparations */
  174 
  175 #endif           /* __GAL_TYPE_H__ */