]> pd.if.org Git - pdclib/blob - includes/inttypes.h
5b868071144317bf646463ad90d31eeb314fb2ec
[pdclib] / includes / inttypes.h
1 /* $Id$ */
2
3 /* 7.8 Format conversion of integer types <inttypes.h>
4
5    This file is part of the Public Domain C Library (PDCLib).
6    Permission is granted to use, modify, and / or redistribute at will.
7 */
8
9 #ifndef _PDCLIB_INTTYPES_H
10 #define _PDCLIB_INTTYPES_H _PDCLIB_INTTYPES_H
11
12 #include <stdint.h>
13
14 typedef struct _PDCLIB_imaxdiv_t imaxdiv_t;
15
16 /* TODO: Print / Scan Macros */
17 /*
18 PRId8   PRIdLEAST8   PRIdFAST8   PRIdMAX
19 PRId16  PRIdLEAST16  PRIdFAST16  PRIdPTR
20 PRId32  PRIdLEAST32  PRIdFAST32
21 PRId64  PRIdLEAST64  PRIdFAST64
22
23 PRIi8   PRIiLEAST8   PRIiFAST8   PRIiMAX
24 PRIi16  PRIiLEAST16  PRIiFAST16  PRIdPTR
25 PRIi32  PRIiLEAST32  PRIiFAST32
26 PRIi64  PRIiLEAST64  PRIiFAST64
27
28 PRIo8   PRIoLEAST8   PRIoFAST8   PRIoMAX
29 PRIo16  PRIoLEAST16  PRIoFAST16  PRIoPTR
30 PRIo32  PRIoLEAST32  PRIoFAST32
31 PRIo64  PRIoLEAST64  PRIoFAST64
32
33 PRIu8   PRIuLEAST8   PRIuFAST8   PRIuMAX
34 PRIu16  PRIuLEAST16  PRIuFAST16  PRIuPTR
35 PRIu32  PRIuLEAST32  PRIuFAST32
36 PRIu64  PRIuLEAST64  PRIuFAST64
37
38 PRIx8   PRIxLEAST8   PRIxFAST8   PRIxMAX
39 PRIx16  PRIxLEAST16  PRIxFAST16  PRIxPTR
40 PRIx32  PRIxLEAST32  PRIxFAST32
41 PRIx64  PRIxLEAST64  PRIxFAST64
42
43 PRIX8   PRIXLEAST8   PRIXFAST8   PRIXMAX
44 PRIX16  PRIXLEAST16  PRIXFAST16  PRIXPTR
45 PRIX32  PRIXLEAST32  PRIXFAST32
46 PRIX64  PRIXLEAST64  PRIXFAST64
47
48 SCNd8   SCNdLEAST8   SCNdFAST8   SCNdMAX
49 SCNd16  SCNdLEAST16  SCNdFAST16  SCNdPTR
50 SCNd32  SCNdLEAST32  SCNdFAST32
51 SCNd64  SCNdLEAST64  SCNdFAST64
52
53 SCNi8   SCNiLEAST8   SCNiFAST8   SCNiMAX
54 SCNi16  SCNiLEAST16  SCNiFAST16  SCNdPTR
55 SCNi32  SCNiLEAST32  SCNiFAST32
56 SCNi64  SCNiLEAST64  SCNiFAST64
57
58 SCNo8   SCNoLEAST8   SCNoFAST8   SCNoMAX
59 SCNo16  SCNoLEAST16  SCNoFAST16  SCNoPTR
60 SCNo32  SCNoLEAST32  SCNoFAST32
61 SCNo64  SCNoLEAST64  SCNoFAST64
62
63 SCNu8   SCNuLEAST8   SCNuFAST8   SCNuMAX
64 SCNu16  SCNuLEAST16  SCNuFAST16  SCNuPTR
65 SCNu32  SCNuLEAST32  SCNuFAST32
66 SCNu64  SCNuLEAST64  SCNuFAST64
67
68 SCNx8   SCNxLEAST8   SCNxFAST8   SCNxMAX
69 SCNx16  SCNxLEAST16  SCNxFAST16  SCNxPTR
70 SCNx32  SCNxLEAST32  SCNxFAST32
71 SCNx64  SCNxLEAST64  SCNxFAST64
72
73 SCNX8   SCNXLEAST8   SCNXFAST8   SCNXMAX
74 SCNX16  SCNXLEAST16  SCNXFAST16  SCNXPTR
75 SCNX32  SCNXLEAST32  SCNXFAST32
76 SCNX64  SCNXLEAST64  SCNXFAST64
77 */
78
79 /* 7.8.2 Functions for greatest-width integer types */
80
81 /* Calculate the absolute value of j */
82 intmax_t imaxabs( intmax_t j );
83
84 /* Return quotient (quot) and remainder (rem) of an integer division in the
85    imaxdiv_t struct.
86 */
87 imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom );
88
89 /* Seperate the character array nptr into three parts: A (possibly empty)
90    sequence of whitespace characters, a character representation of an integer
91    to the given base, and trailing invalid characters (including the terminating
92    null character). If base is 0, assume it to be 10, unless the integer
93    representation starts with 0x / 0X (setting base to 16) or 0 (setting base to
94    8). If given, base can be anything from 0 to 36, using the 26 letters of the
95    base alphabet (both lowercase and uppercase) as digits 10 through 35.
96    The integer representation is then converted into the return type of the
97    function. It can start with a '+' or '-' sign. If the sign is '-', the result
98    of the conversion is negated.
99    If the conversion is successful, the converted value is returned. If endptr
100    is not a NULL pointer, a pointer to the first trailing invalid character is
101    returned in *endptr.
102    If no conversion could be performed, zero is returned (and nptr in *endptr,
103    if endptr is not a NULL pointer). If the converted value does not fit into
104    the return type, the functions return INTMAX_MIN, INTMAX_MAX, or UINTMAX_MAX,
105    respectively, depending on the sign of the integer representation and the
106    return type, and errno is set to ERANGE.
107 */
108 /* This function is equivalent to strtol() / strtoul() in <stdlib.h>, but on
109    the potentially larger type.
110 */
111 intmax_t strtoimax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
112 uintmax_t strtoumax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
113
114 /* TODO: wcstoimax(), wcstoumax() */
115
116 #endif
117