Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /****************************************************************************
  2. *
  3. *                            Open Watcom Project
  4. *
  5. *    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
  6. *
  7. *  ========================================================================
  8. *
  9. *    This file contains Original Code and/or Modifications of Original
  10. *    Code as defined in and that are subject to the Sybase Open Watcom
  11. *    Public License version 1.0 (the 'License'). You may not use this file
  12. *    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
  13. *    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
  14. *    provided with the Original Code and Modifications, and is also
  15. *    available at www.sybase.com/developer/opensource.
  16. *
  17. *    The Original Code and all software distributed under the License are
  18. *    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  19. *    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
  20. *    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
  21. *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
  22. *    NON-INFRINGEMENT. Please see the License for the specific language
  23. *    governing rights and limitations under the License.
  24. *
  25. *  ========================================================================
  26. *
  27. * Description:  Definitions needed by callers to internal string formatter
  28. *               __prtf() for printf() style handling.
  29. *
  30. ****************************************************************************/
  31.  
  32.  
  33. #ifndef _PRINTF_H_INCLUDED
  34. #define _PRINTF_H_INCLUDED
  35.  
  36. #include "variety.h"
  37. #include "widechar.h"
  38.  
  39. #if defined(__QNX__)
  40.     #if defined(__386__)
  41.         #define __SLIB_CALLBACK _WCFAR
  42.         #define __SLIB
  43.         #pragma aux slib_callback_t __far parm [eax] [edx] modify [eax edx];
  44.     #elif defined( __SMALL_DATA__ )
  45.         #define __SLIB_CALLBACK _WCFAR __loadds
  46.         #define __SLIB          _WCFAR
  47.     #else
  48.         #define __SLIB_CALLBACK _WCFAR
  49.         #define __SLIB          _WCFAR
  50.     #endif
  51. #else
  52.     #if defined( __HUGE__ )
  53.         #define __SLIB          _WCFAR
  54.         #define __SLIB_CALLBACK
  55.     #else
  56.         #define __SLIB
  57.         #define __SLIB_CALLBACK
  58.     #endif
  59. #endif
  60.  
  61. #define SPECS_VERSION           200
  62.  
  63. /*
  64.  * This is the __prtf specs structure. NB - should be naturally aligned.
  65.  *
  66.  * There are both wide and MBCS versions explicitly because part of __wprtf
  67.  * needs to access both kinds of structure.
  68.  */
  69.  
  70. typedef struct
  71. {
  72.     char    __SLIB *_dest;
  73.     short           _flags;         // flags (see below)
  74.     short           _version;       // structure version # (2.0 --> 200)
  75.     int             _fld_width;     // field width
  76.     int             _prec;          // precision
  77.     int             _output_count;  // # of characters outputted for %n
  78.     int             _n0;            // number of chars to deliver first
  79.     int             _nz0;           // number of zeros to deliver next
  80.     int             _n1;            // number of chars to deliver next
  81.     int             _nz1;           // number of zeros to deliver next
  82.     int             _n2;            // number of chars to deliver next
  83.     int             _nz2;           // number of zeros to deliver next
  84.     char            _character;     // format character
  85.     char            _pad_char;
  86.     char            _padding[2];    // to keep struct aligned
  87. } _mbcs_SPECS;
  88.  
  89. typedef struct
  90. {
  91.     wchar_t __SLIB *_dest;
  92.     short           _flags;         // flags (see below)
  93.     short           _version;       // structure version # (2.0 --> 200)
  94.     int             _fld_width;     // field width
  95.     int             _prec;          // precision
  96.     int             _output_count;  // # of characters outputted for %n
  97.     int             _n0;            // number of chars to deliver first
  98.     int             _nz0;           // number of zeros to deliver next
  99.     int             _n1;            // number of chars to deliver next
  100.     int             _nz1;           // number of zeros to deliver next
  101.     int             _n2;            // number of chars to deliver next
  102.     int             _nz2;           // number of zeros to deliver next
  103.     wchar_t         _character;     // format character
  104.     wchar_t         _pad_char;
  105. } _wide_SPECS;
  106.  
  107. #ifdef __WIDECHAR__
  108.     #define SPECS               _wide_SPECS
  109. #else
  110.     #define SPECS               _mbcs_SPECS
  111. #endif
  112.  
  113.  
  114. typedef void (__SLIB_CALLBACK slib_callback_t)( SPECS __SLIB *, int );
  115.  
  116. /* specification flags... (values for _flags field above) */
  117.  
  118. #define SPF_ALT         0x0001
  119. #define SPF_BLANK       0x0002
  120. #define SPF_FORCE_SIGN  0x0004
  121. #define SPF_LEFT_ADJUST 0x0008
  122. #define SPF_CHAR        0x0010
  123. #define SPF_SHORT       0x0020
  124. #define SPF_LONG        0x0040
  125. #define SPF_LONG_LONG   0x0080
  126. #define SPF_LONG_DOUBLE 0x0100          // may be also used for __int64
  127. #define SPF_NEAR        0x0200
  128. #define SPF_FAR         0x0400
  129. #define SPF_CVT         0x0800          // __cvt function
  130.  
  131. #ifdef __QNX__
  132. #define SPF_ZERO_PAD    0x8000
  133. #endif // __QNX__
  134.  
  135. #if defined( __STDC_WANT_LIB_EXT1__ ) && __STDC_WANT_LIB_EXT1__ == 1
  136.  
  137. #if !defined( __WIDECHAR__ )
  138. int __prtf_s( void __SLIB *dest,                /* parm for use by out_putc */
  139.             const char * __restrict format,     /* pointer to format string */
  140.             va_list args,                       /* pointer to pointer to args*/
  141.             const char **errmsg,                /* constraint violation msg */
  142.             slib_callback_t *out_putc );        /* character output routine */
  143.  
  144. #else
  145. int __wprtf_s( void __SLIB *dest,               /* parm for use by out_putc */
  146.             const CHAR_TYPE * __restrict format,/* pointer to format string */
  147.             va_list args,                       /* pointer to pointer to args*/
  148.             const char **errmsg,                /* constraint violation msg */
  149.             slib_callback_t *out_putc );        /* character output routine */
  150. #endif
  151.  
  152. #else
  153.  
  154. #if !defined(__WIDECHAR__)
  155. int __prtf( void __SLIB *dest,                  /* parm for use by out_putc */
  156.                 const char *format,             /* pointer to format string */
  157.                 va_list args,                   /* pointer to pointer to args*/
  158.                 slib_callback_t *out_putc );    /* character output routine */
  159.  
  160. #else
  161. int __wprtf( void __SLIB *dest,                 /* parm for use by out_putc */
  162.                 const CHAR_TYPE *format,        /* pointer to format string */
  163.                 va_list args,                   /* pointer to pointer to args*/
  164.                 slib_callback_t *out_putc );    /* character output routine */
  165. #endif
  166.  
  167. #ifdef __QNX__
  168. int __prtf_slib( void __SLIB *dest,             /* parm for use by out_putc */
  169.                 const char * format,            /* pointer to format string */
  170.                 char **args,                    /* pointer to pointer to args*/
  171.                 slib_callback_t *out_putc,      /* character output routine */
  172.                 int ptr_size );
  173.  
  174.     #if !defined(IN_SLIB) && !defined(__386__)
  175.         extern int ( _WCFAR * ( _WCFAR *__f)) ();
  176.         #define __prtf(a,b,c,d) __prtf_slib(a,b,c,d,sizeof(void *))
  177.         #define __prtf_slib(a,b,c,d,e) ((int(_WCFAR *) (void _WCFAR *,const char _WCFAR *,char * _WCFAR *args,void (_WCFAR *__out)(SPECS _WCFAR *,int),int)) __f[24])(a,b,c,d,e)
  178.     #endif
  179. #endif
  180.  
  181. #endif  /* Safer C */
  182.  
  183. #endif
  184.