]> pd.if.org Git - pdclib/blobdiff - includes/inttypes.h
Almost done on tmpfile / tmpnam.
[pdclib] / includes / inttypes.h
old mode 100644 (file)
new mode 100755 (executable)
index bb52ea9..a0b0f35
-// ----------------------------------------------------------------------------
-// $Id$
-// ----------------------------------------------------------------------------
-// Public Domain C Library - http://pdclib.sourceforge.net
-// This code is Public Domain. Use, modify, and redistribute at will.
-// ----------------------------------------------------------------------------
-// Format conversion of integer types
-// ----------------------------------------------------------------------------
-
-#ifndef __INTTYPES_H
-#define __INTTYPES_H __INTTYPES_H
-
-// ----------------------------------------------------------------------------
-// TYPEDEFS
-
-typedef struct
-{
- intmax_t quotient,
- intmax_t remainder;
-}
-imaxdiv_t;
-
-// ----------------------------------------------------------------------------
-// FUNCTIONS
-
-intmax_t imaxabs( intmax_t i );
-intmax_t abs( intmax_t i ); [C++ only]
-
+/* $Id$ */
+
+/* 7.8 Format conversion of integer types <inttypes.h>
+
+   This file is part of the Public Domain C Library (PDCLib).
+   Permission is granted to use, modify, and / or redistribute at will.
+*/
+
+#ifndef _PDCLIB_INTTYPES_H
+#define _PDCLIB_INTTYPES_H _PDCLIB_INTTYPES_H
+
+#include <stdint.h>
+
+typedef struct _PDCLIB_imaxdiv_t imaxdiv_t;
+
+#define SCNu32 "u"
+#define PRNu32 "u"
+/* TODO: Print / Scan Macros */
+/*
+PRId8   PRIdLEAST8   PRIdFAST8   PRIdMAX
+PRId16  PRIdLEAST16  PRIdFAST16  PRIdPTR
+PRId32  PRIdLEAST32  PRIdFAST32
+PRId64  PRIdLEAST64  PRIdFAST64
+
+PRIi8   PRIiLEAST8   PRIiFAST8   PRIiMAX
+PRIi16  PRIiLEAST16  PRIiFAST16  PRIdPTR
+PRIi32  PRIiLEAST32  PRIiFAST32
+PRIi64  PRIiLEAST64  PRIiFAST64
+
+PRIo8   PRIoLEAST8   PRIoFAST8   PRIoMAX
+PRIo16  PRIoLEAST16  PRIoFAST16  PRIoPTR
+PRIo32  PRIoLEAST32  PRIoFAST32
+PRIo64  PRIoLEAST64  PRIoFAST64
+
+PRIu8   PRIuLEAST8   PRIuFAST8   PRIuMAX
+PRIu16  PRIuLEAST16  PRIuFAST16  PRIuPTR
+PRIu32  PRIuLEAST32  PRIuFAST32
+PRIu64  PRIuLEAST64  PRIuFAST64
+
+PRIx8   PRIxLEAST8   PRIxFAST8   PRIxMAX
+PRIx16  PRIxLEAST16  PRIxFAST16  PRIxPTR
+PRIx32  PRIxLEAST32  PRIxFAST32
+PRIx64  PRIxLEAST64  PRIxFAST64
+
+PRIX8   PRIXLEAST8   PRIXFAST8   PRIXMAX
+PRIX16  PRIXLEAST16  PRIXFAST16  PRIXPTR
+PRIX32  PRIXLEAST32  PRIXFAST32
+PRIX64  PRIXLEAST64  PRIXFAST64
+
+SCNd8   SCNdLEAST8   SCNdFAST8   SCNdMAX
+SCNd16  SCNdLEAST16  SCNdFAST16  SCNdPTR
+SCNd32  SCNdLEAST32  SCNdFAST32
+SCNd64  SCNdLEAST64  SCNdFAST64
+
+SCNi8   SCNiLEAST8   SCNiFAST8   SCNiMAX
+SCNi16  SCNiLEAST16  SCNiFAST16  SCNdPTR
+SCNi32  SCNiLEAST32  SCNiFAST32
+SCNi64  SCNiLEAST64  SCNiFAST64
+
+SCNo8   SCNoLEAST8   SCNoFAST8   SCNoMAX
+SCNo16  SCNoLEAST16  SCNoFAST16  SCNoPTR
+SCNo32  SCNoLEAST32  SCNoFAST32
+SCNo64  SCNoLEAST64  SCNoFAST64
+
+SCNu8   SCNuLEAST8   SCNuFAST8   SCNuMAX
+SCNu16  SCNuLEAST16  SCNuFAST16  SCNuPTR
+SCNu32  SCNuLEAST32  SCNuFAST32
+SCNu64  SCNuLEAST64  SCNuFAST64
+
+SCNx8   SCNxLEAST8   SCNxFAST8   SCNxMAX
+SCNx16  SCNxLEAST16  SCNxFAST16  SCNxPTR
+SCNx32  SCNxLEAST32  SCNxFAST32
+SCNx64  SCNxLEAST64  SCNxFAST64
+
+SCNX8   SCNXLEAST8   SCNXFAST8   SCNXMAX
+SCNX16  SCNXLEAST16  SCNXFAST16  SCNXPTR
+SCNX32  SCNXLEAST32  SCNXFAST32
+SCNX64  SCNXLEAST64  SCNXFAST64
+*/
+
+/* 7.8.2 Functions for greatest-width integer types */
+
+/* Calculate the absolute value of j */
+intmax_t imaxabs( intmax_t j );
+
+/* Return quotient (quot) and remainder (rem) of an integer division in the
+   imaxdiv_t struct.
+*/
 imaxdiv_t imaxdiv( intmax_t numer, intmax_t denom );
-imaxdiv_t div( intmax_t numer, intmax_t denom ); [C++ only]
-
-intmax_t strtoimax( const char * restrict s, char * * restrict endptr, int base );
-uintmax_t strtoumax( const char * restrict s, char * * restrict endptr, int base );
-intmax_t wcstoimax( const wchar_t * restrict s, wchar_t * * restrict endptr, int base );
-uintmax_t wcstoumax( const wchar_t * restrict s, wchar_t * * restrict endptr, int base );
-
-// ----------------------------------------------------------------------------
-// MACROS (PRINT)
-
-#define PRId8
-#define PRId16
-#define PRId32
-#define PRId64
-
-#define PRIdFAST8
-#define PRIdFAST16
-#define PRIdFAST32
-#define PRIdFAST64
-
-#define PRIdLEAST8
-#define PRIdLEAST16
-#define PRIdLEAST32
-#define PRIdLEAST64
-
-#define PRIdMAX
-#define PRIdPTR
-
-#define PRIi8
-#define PRIi16
-#define PRIi32
-#define PRIi64
-
-#define PRIiFAST8
-#define PRIiFAST16
-#define PRIiFAST32
-#define PRIiFAST64
-
-#define PRIiLEAST8
-#define PRIiLEAST16
-#define PRIiLEAST32
-#define PRIiLEAST64
-
-#define PRIiMAX
-#define PRIiPTR
-
-#define PRIo8
-#define PRIo16
-#define PRIo32
-#define PRIo64
-
-#define PRIoFAST8
-#define PRIoFAST16
-#define PRIoFAST32
-#define PRIoFAST64
-
-#define PRIoLEAST8
-#define PRIoLEAST16
-#define PRIoLEAST32
-#define PRIoLEAST64
-
-#define PRIoMAX
-#define PRIoPTR
-
-#define PRIu8
-#define PRIu16
-#define PRIu32
-#define PRIu64
-
-#define PRIuFAST8
-#define PRIuFAST16
-#define PRIuFAST32
-#define PRIuFAST64
-
-#define PRIuLEAST8
-#define PRIuLEAST16
-#define PRIuLEAST32
-#define PRIuLEAST64
-
-#define PRIuMAX
-#define PRIuPTR
-
-#define PRIx8
-#define PRIx16
-#define PRIx32
-#define PRIx64
-
-#define PRIxFAST8
-#define PRIxFAST16
-#define PRIxFAST32
-#define PRIxFAST64
-
-#define PRIxLEAST8
-#define PRIxLEAST16
-#define PRIxLEAST32
-#define PRIxLEAST64
-
-#define PRIxMAX
-#define PRIxPTR
-
-#define PRIX8
-#define PRIX16
-#define PRIX32
-#define PRIX64
-
-#define PRIXFAST8
-#define PRIXFAST16
-#define PRIXFAST32
-#define PRIXFAST64
-
-#define PRIXLEAST8
-#define PRIXLEAST16
-#define PRIXLEAST32
-#define PRIXLEAST64
-
-#define PRIXMAX
-#define PRIXPTR
-
-// ----------------------------------------------------------------------------
-// MACROS (SCAN)
-
-#define SCNd8
-#define SCNd16
-#define SCNd32
-#define SCNd64
-
-#define SCNdFAST8
-#define SCNdFAST16
-#define SCNdFAST32
-#define SCNdFAST64
-
-#define SCNdLEAST8
-#define SCNdLEAST16
-#define SCNdLEAST32
-#define SCNdLEAST64
-
-#define SCNdMAX
-#define SCNdPTR
-
-#define SCNi8
-#define SCNi16
-#define SCNi32
-#define SCNi64
-
-#define SCNiFAST8
-#define SCNiFAST16
-#define SCNiFAST32
-#define SCNiFAST64
-
-#define SCNiLEAST8
-#define SCNiLEAST16
-#define SCNiLEAST32
-#define SCNiLEAST64
-
-#define SCNiMAX
-#define SCNiPTR
-
-#define SCNo8
-#define SCNo16
-#define SCNo32
-#define SCNo64
-
-#define SCNoFAST8
-#define SCNoFAST16
-#define SCNoFAST32
-#define SCNoFAST64
-
-#define SCNoLEAST8
-#define SCNoLEAST16
-#define SCNoLEAST32
-#define SCNoLEAST64
-
-#define SCNoMAX
-#define SCNoPTR
-
-#define SCNu8
-#define SCNu16
-#define SCNu32
-#define SCNu64
-
-#define SCNuFAST8
-#define SCNuFAST16
-#define SCNuFAST32
-#define SCNuFAST64
-
-#define SCNuLEAST8
-#define SCNuLEAST16
-#define SCNuLEAST32
-#define SCNuLEAST64
-
-#define SCNuMAX
-#define SCNuPTR
-
-#define SCNx8
-#define SCNx16
-#define SCNx32
-#define SCNx64
-
-#define SCNxFAST8
-#define SCNxFAST16
-#define SCNxFAST32
-#define SCNxFAST64
-
-#define SCNxLEAST8
-#define SCNxLEAST16
-#define SCNxLEAST32
-#define SCNxLEAST64
-
-#define SCNxMAX
-#define SCNxPTR
-
-#define SCNX8
-#define SCNX16
-#define SCNX32
-#define SCNX64
-
-#define SCNXFAST8
-#define SCNXFAST16
-#define SCNXFAST32
-#define SCNXFAST64
-
-#define SCNXLEAST8
-#define SCNXLEAST16
-#define SCNXLEAST32
-#define SCNXLEAST64
 
-#define SCNXMAX
-#define SCNXPTR
+/* Seperate the character array nptr into three parts: A (possibly empty)
+   sequence of whitespace characters, a character representation of an integer
+   to the given base, and trailing invalid characters (including the terminating
+   null character). If base is 0, assume it to be 10, unless the integer
+   representation starts with 0x / 0X (setting base to 16) or 0 (setting base to
+   8). If given, base can be anything from 0 to 36, using the 26 letters of the
+   base alphabet (both lowercase and uppercase) as digits 10 through 35.
+   The integer representation is then converted into the return type of the
+   function. It can start with a '+' or '-' sign. If the sign is '-', the result
+   of the conversion is negated.
+   If the conversion is successful, the converted value is returned. If endptr
+   is not a NULL pointer, a pointer to the first trailing invalid character is
+   returned in *endptr.
+   If no conversion could be performed, zero is returned (and nptr in *endptr,
+   if endptr is not a NULL pointer). If the converted value does not fit into
+   the return type, the functions return INTMAX_MIN, INTMAX_MAX, or UINTMAX_MAX,
+   respectively, depending on the sign of the integer representation and the
+   return type, and errno is set to ERANGE.
+*/
+/* This function is equivalent to strtol() / strtoul() in <stdlib.h>, but on
+   the potentially larger type.
+*/
+intmax_t strtoimax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
+uintmax_t strtoumax( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
+
+/* TODO: wcstoimax(), wcstoumax() */
+
+#endif
 
-#endif // __INTTYPES_H