home *** CD-ROM | disk | FTP | other *** search
/ Oracle Video Server 3.0.3.1 / OVS_3031_NT.iso / win32 / medianet / server / include / ysfmt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-06  |  2.9 KB  |  95 lines

  1. /* Copyright (c) Oracle Corporation 1995.  All Rights Reserved.
  2.  *
  3.  * ysfmt.h - String Formating.
  4.  *
  5.  * NOTE: These functions exist since it is not possible to construct a va_list
  6.  * and to allow for "custom" extensions like the formating of transport layer
  7.  * addresses and sysb8s.
  8.  *
  9.  * DESCRIPTION
  10.  * ysfmt currently supports a subset of the ANSI C specified format string. The
  11.  * flags supported are - and 0.  Field width followed by an optional precision
  12.  * is supported.  The conversion character prefix L implies an sysb8. The
  13.  * conversion characters u,d,x,c and s are also supported.
  14.  *
  15.  * The following flags and conversions are *NOT* currently supported:
  16.  *  +,<space>,#,i,o,f,e,E,g,G,p,n
  17.  *
  18.  * ATTRS: public, external
  19.  */
  20.  
  21. #ifndef YSFMT_ORACLE
  22. #define YSFMT_ORACLE
  23.  
  24. #ifndef SYSX_ORACLE
  25. #include <sysx.h>
  26. #endif
  27.  
  28. EXTC_START
  29.  
  30. /* PUBLIC TYPES AND CONSTANTS */
  31. typedef struct ysfmtd ysfmtd;
  32.  
  33. /* types for descriptor list elements */
  34. #define YSFMT_BAD (ub4) 0
  35. #define YSFMT_UB1 (ub4) 1
  36. #define YSFMT_SB1 (ub4) 2
  37. #define YSFMT_UB4 (ub4) 3
  38. #define YSFMT_SB4 (ub4) 4
  39. #define YSFMT_STR (ub4) 5
  40. #define YSFMT_SB8 (ub4) 6
  41.  
  42. /*
  43.  * ysFmtStr, ysFmtStrl - format a string much like sprintf()
  44.  *
  45.  * DESCRIPTION
  46.  * ysFmtStr is intended as a replacement for sprintf().  Its interface is
  47.  * identical.
  48.  *
  49.  * ysFmtStrl is identical to ysFmtStr, but the output size is limited by
  50.  * the size parameter.
  51.  *
  52.  * Both ysFmtStr and ysFmtStrl build a typed argument descriptor list from
  53.  * the arguments specified per the format strings specification.  The format
  54.  * string and argument descriptor list is then passed to ysFmtStrDesc() for
  55.  * formatting.
  56.  */
  57. void ysFmtStr(char *out,CONST char *fmt, ...);
  58. void ysFmtStrl(char *out, size_t size, CONST char *fmt, ...);
  59. void ysFmtVaStrl(char *out, size_t size, CONST char *fmt, va_list args);
  60.  
  61. /* 
  62.  * ysFmtDescCreate, ysFmtDescDestroy, ysFmtAddElem
  63.  *   - typed argument descriptor list manipulation.
  64.  *
  65.  * DESCRIPTION
  66.  *
  67.  * ysFmtDescCreate() creates and returns an empty typed argument descriptor
  68.  * list.
  69.  *
  70.  * ysFmtDescDestroy() destroys a typed argument descriptor list.
  71.  *
  72.  * ysFmtDescAddElem() adds an element (type and value) to the end of 
  73.  * the descriptor list.  All values except for YSFMT_STR are copied into the
  74.  * descriptor list itself so storage need only persist for YSFMT_STRs.
  75.  *
  76.  */
  77.  
  78. ysfmtd *ysFmtDescCreate(void);
  79. void ysFmtDescDestroy(ysfmtd *d);
  80. ysfmtd *ysFmtAddElem(ysfmtd *d, ub4 type, dvoid *value);
  81.  
  82. /*
  83.  * ysFmtStrDesc - format a string using a typed descriptor list
  84.  *
  85.  * DESCRIPTION
  86.  * ysFmtStrDesc formats the list typed arguments according the the format
  87.  * string specified.  The size of the output string is limited by the size
  88.  * parameter.  The output string is truncated to size-1 characters and '\0'
  89.  * terminated.
  90.  */
  91. void ysFmtStrDesc(char *out, size_t size, CONST char *fmt, ysfmtd *d);
  92.  
  93. EXTC_END
  94. #endif
  95.