gnunet-android

GNUnet for Android
Log | Files | Refs | README

unistdio.h (10195B)


      1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
      2 /* Elementary Unicode string functions.
      3    Copyright (C) 2002, 2005-2007, 2009-2024 Free Software Foundation, Inc.
      4 
      5    This file is free software.
      6    It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
      7    You can redistribute it and/or modify it under either
      8      - the terms of the GNU Lesser General Public License as published
      9        by the Free Software Foundation, either version 3, or (at your
     10        option) any later version, or
     11      - the terms of the GNU General Public License as published by the
     12        Free Software Foundation; either version 2, or (at your option)
     13        any later version, or
     14      - the same dual license "the GNU LGPLv3+ or the GNU GPLv2+".
     15 
     16    This file is distributed in the hope that it will be useful,
     17    but WITHOUT ANY WARRANTY; without even the implied warranty of
     18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19    Lesser General Public License and the GNU General Public License
     20    for more details.
     21 
     22    You should have received a copy of the GNU Lesser General Public
     23    License and of the GNU General Public License along with this
     24    program.  If not, see <https://www.gnu.org/licenses/>.  */
     25 
     26 #ifndef _UNISTDIO_H
     27 #define _UNISTDIO_H
     28 
     29 #include "unitypes.h"
     30 
     31 /* Get size_t.  */
     32 #include <stddef.h>
     33 
     34 /* Get FILE.  */
     35 #include <stdio.h>
     36 
     37 /* Get va_list.  */
     38 #include <stdarg.h>
     39 
     40 #ifdef __cplusplus
     41 extern "C" {
     42 #endif
     43 
     44 /* These work like the printf function family.
     45    In the format string:
     46    The format directive 'U' takes an UTF-8 string (const uint8_t *).
     47    The format directive 'lU' takes an UTF-16 string (const uint16_t *).
     48    The format directive 'llU' takes an UTF-32 string (const uint32_t *).
     49 
     50    The prefix (ulc_, u8_, u16_, u16_) indicates the type of the resulting
     51    string.  The prefix 'ulc' stands for "locale encoded".
     52 
     53    An infix 'v' indicates that a va_list is passed instead of multiple
     54    arguments.
     55 
     56    The functions *sprintf have a 'buf' argument that is assumed to be large
     57    enough.  (DANGEROUS!  Overflowing the buffer will crash the program.)
     58    The functions *snprintf have a 'buf' argument that is assumed to be 'size'
     59    units large.  (DANGEROUS!  The resulting string might be truncated in the
     60    middle of a multibyte character.)
     61    The functions *asprintf have a 'resultp' argument.  The result will be
     62    freshly allocated and stored in *resultp.
     63    The functions *asnprintf have a (resultbuf, lengthp) argument pair.  If
     64    resultbuf is not NULL and the result fits into *lengthp units, it is put
     65    in resultbuf, and resultbuf is returned.  Otherwise, a freshly allocated
     66    string is returned.  In both cases, *lengthp is set to the length (number
     67    of units) of the returned string.  In case of error, NULL is returned and
     68    errno is set.
     69  */
     70 
     71 /* ASCII format string, result in locale dependent encoded 'char *'.  */
     72 extern int
     73        ulc_sprintf (char *_UC_RESTRICT buf,
     74                     const char *format, ...);
     75 extern int
     76        ulc_snprintf (char *_UC_RESTRICT buf, size_t size,
     77                      const char *format, ...);
     78 extern int
     79        ulc_asprintf (char **resultp,
     80                      const char *format, ...);
     81 extern char *
     82        ulc_asnprintf (char *_UC_RESTRICT resultbuf, size_t *lengthp,
     83                       const char *format, ...);
     84 extern int
     85        ulc_vsprintf (char *_UC_RESTRICT buf,
     86                      const char *format, va_list ap);
     87 extern int
     88        ulc_vsnprintf (char *_UC_RESTRICT buf, size_t size,
     89                       const char *format, va_list ap);
     90 extern int
     91        ulc_vasprintf (char **resultp,
     92                       const char *format, va_list ap);
     93 extern char *
     94        ulc_vasnprintf (char *_UC_RESTRICT resultbuf, size_t *lengthp,
     95                        const char *format, va_list ap);
     96 
     97 /* ASCII format string, result in UTF-8 format.  */
     98 extern int
     99        u8_sprintf (uint8_t *buf,
    100                    const char *format, ...);
    101 extern int
    102        u8_snprintf (uint8_t *buf, size_t size,
    103                     const char *format, ...);
    104 extern int
    105        u8_asprintf (uint8_t **resultp,
    106                     const char *format, ...);
    107 extern uint8_t *
    108        u8_asnprintf (uint8_t *resultbuf, size_t *lengthp,
    109                      const char *format, ...);
    110 extern int
    111        u8_vsprintf (uint8_t *buf,
    112                     const char *format, va_list ap);
    113 extern int
    114        u8_vsnprintf (uint8_t *buf, size_t size,
    115                      const char *format, va_list ap);
    116 extern int
    117        u8_vasprintf (uint8_t **resultp,
    118                      const char *format, va_list ap);
    119 extern uint8_t *
    120        u8_vasnprintf (uint8_t *resultbuf, size_t *lengthp,
    121                       const char *format, va_list ap);
    122 
    123 /* UTF-8 format string, result in UTF-8 format.  */
    124 extern int
    125        u8_u8_sprintf (uint8_t *_UC_RESTRICT buf,
    126                       const uint8_t *format, ...);
    127 extern int
    128        u8_u8_snprintf (uint8_t *_UC_RESTRICT buf, size_t size,
    129                        const uint8_t *format, ...);
    130 extern int
    131        u8_u8_asprintf (uint8_t **resultp,
    132                        const uint8_t *format, ...);
    133 extern uint8_t *
    134        u8_u8_asnprintf (uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp,
    135                         const uint8_t *format, ...);
    136 extern int
    137        u8_u8_vsprintf (uint8_t *_UC_RESTRICT buf,
    138                        const uint8_t *format, va_list ap);
    139 extern int
    140        u8_u8_vsnprintf (uint8_t *_UC_RESTRICT buf, size_t size,
    141                         const uint8_t *format, va_list ap);
    142 extern int
    143        u8_u8_vasprintf (uint8_t **resultp,
    144                         const uint8_t *format, va_list ap);
    145 extern uint8_t *
    146        u8_u8_vasnprintf (uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp,
    147                          const uint8_t *format, va_list ap);
    148 
    149 /* ASCII format string, result in UTF-16 format.  */
    150 extern int
    151        u16_sprintf (uint16_t *buf,
    152                     const char *format, ...);
    153 extern int
    154        u16_snprintf (uint16_t *buf, size_t size,
    155                      const char *format, ...);
    156 extern int
    157        u16_asprintf (uint16_t **resultp,
    158                      const char *format, ...);
    159 extern uint16_t *
    160        u16_asnprintf (uint16_t *resultbuf, size_t *lengthp,
    161                       const char *format, ...);
    162 extern int
    163        u16_vsprintf (uint16_t *buf,
    164                      const char *format, va_list ap);
    165 extern int
    166        u16_vsnprintf (uint16_t *buf, size_t size,
    167                       const char *format, va_list ap);
    168 extern int
    169        u16_vasprintf (uint16_t **resultp,
    170                       const char *format, va_list ap);
    171 extern uint16_t *
    172        u16_vasnprintf (uint16_t *resultbuf, size_t *lengthp,
    173                        const char *format, va_list ap);
    174 
    175 /* UTF-16 format string, result in UTF-16 format.  */
    176 extern int
    177        u16_u16_sprintf (uint16_t *_UC_RESTRICT buf,
    178                         const uint16_t *format, ...);
    179 extern int
    180        u16_u16_snprintf (uint16_t *_UC_RESTRICT buf, size_t size,
    181                          const uint16_t *format, ...);
    182 extern int
    183        u16_u16_asprintf (uint16_t **resultp,
    184                          const uint16_t *format, ...);
    185 extern uint16_t *
    186        u16_u16_asnprintf (uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp,
    187                           const uint16_t *format, ...);
    188 extern int
    189        u16_u16_vsprintf (uint16_t *_UC_RESTRICT buf,
    190                          const uint16_t *format, va_list ap);
    191 extern int
    192        u16_u16_vsnprintf (uint16_t *_UC_RESTRICT buf, size_t size,
    193                           const uint16_t *format, va_list ap);
    194 extern int
    195        u16_u16_vasprintf (uint16_t **resultp,
    196                           const uint16_t *format, va_list ap);
    197 extern uint16_t *
    198        u16_u16_vasnprintf (uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp,
    199                            const uint16_t *format, va_list ap);
    200 
    201 /* ASCII format string, result in UTF-32 format.  */
    202 extern int
    203        u32_sprintf (uint32_t *buf,
    204                     const char *format, ...);
    205 extern int
    206        u32_snprintf (uint32_t *buf, size_t size,
    207                      const char *format, ...);
    208 extern int
    209        u32_asprintf (uint32_t **resultp,
    210                      const char *format, ...);
    211 extern uint32_t *
    212        u32_asnprintf (uint32_t *resultbuf, size_t *lengthp,
    213                       const char *format, ...);
    214 extern int
    215        u32_vsprintf (uint32_t *buf,
    216                      const char *format, va_list ap);
    217 extern int
    218        u32_vsnprintf (uint32_t *buf, size_t size,
    219                       const char *format, va_list ap);
    220 extern int
    221        u32_vasprintf (uint32_t **resultp,
    222                       const char *format, va_list ap);
    223 extern uint32_t *
    224        u32_vasnprintf (uint32_t *resultbuf, size_t *lengthp,
    225                        const char *format, va_list ap);
    226 
    227 /* UTF-32 format string, result in UTF-32 format.  */
    228 extern int
    229        u32_u32_sprintf (uint32_t *_UC_RESTRICT buf,
    230                         const uint32_t *format, ...);
    231 extern int
    232        u32_u32_snprintf (uint32_t *_UC_RESTRICT buf, size_t size,
    233                          const uint32_t *format, ...);
    234 extern int
    235        u32_u32_asprintf (uint32_t **resultp,
    236                          const uint32_t *format, ...);
    237 extern uint32_t *
    238        u32_u32_asnprintf (uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp,
    239                           const uint32_t *format, ...);
    240 extern int
    241        u32_u32_vsprintf (uint32_t *_UC_RESTRICT buf,
    242                          const uint32_t *format, va_list ap);
    243 extern int
    244        u32_u32_vsnprintf (uint32_t *_UC_RESTRICT buf, size_t size,
    245                           const uint32_t *format, va_list ap);
    246 extern int
    247        u32_u32_vasprintf (uint32_t **resultp,
    248                           const uint32_t *format, va_list ap);
    249 extern uint32_t *
    250        u32_u32_vasnprintf (uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp,
    251                            const uint32_t *format, va_list ap);
    252 
    253 /* ASCII format string, output to FILE in locale dependent encoding.  */
    254 extern int
    255        ulc_fprintf (FILE *stream,
    256                     const char *format, ...);
    257 extern int
    258        ulc_vfprintf (FILE *stream,
    259                      const char *format, va_list ap);
    260 
    261 #ifdef __cplusplus
    262 }
    263 #endif
    264 
    265 #endif /* _UNISTDIO_H */