home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / nls / mcprtlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-20  |  5.2 KB  |  189 lines

  1. #ifndef mcprtlib_h
  2. #define mcprtlib_h
  3.  
  4.  
  5.  
  6. /***********************************************************
  7. Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
  8.  
  9.                         All Rights Reserved
  10.  
  11. Permission to use, copy, modify, and distribute this software and its
  12. documentation for any purpose and without fee is hereby granted,
  13. provided that the above copyright notice appear in all copies and that
  14. both that copyright notice and this permission notice appear in
  15. supporting documentation, and that Alfalfa's name not be used in
  16. advertising or publicity pertaining to distribution of the software
  17. without specific, written prior permission.
  18.  
  19. ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  21. ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  22. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  23. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  24. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  25. SOFTWARE.
  26.  
  27. If you make any modifications, bugfixes or other changes to this software
  28. we'd appreciate it if you could send a copy to us so we can keep things
  29. up-to-date.  Many thanks.
  30.                 Kee Hinckley
  31.                 Alfalfa Software, Inc.
  32.                 267 Allston St., #3
  33.                 Cambridge, MA 02139  USA
  34.                 nazgul@alfalfa.com
  35.     
  36. ******************************************************************/
  37.  
  38.  
  39. /* Edit History
  40.  
  41. 03/20/91   2 schulert    Ultrix cc has trouble with void*, so change them to int*
  42. 01/18/91   3 hamilton    #if not rescanned
  43. 01/12/91   1 schulert    conditionally use prototypes
  44.             rework to use either varargs or stdarg
  45. 11/03/90   2 hamilton    Alphalpha->Alfalfa & OmegaMail->Poste
  46. 08/10/90   1 nazgul    Initial version
  47. */
  48.  
  49. /* taken from Xm/lib/VaSimple.h
  50.    currently no one defines MISSING_STDARG_H */
  51.  
  52. #ifdef    I_STDARG
  53. # include <stdarg.h>
  54. # define Va_start(a,b) va_start(a,b)
  55. #else
  56. # include <varargs.h>
  57. # define Va_start(a,b) va_start(a)
  58. #endif
  59.  
  60. #define MCFree        0x0010            /* Reminder to MCPrintFree */
  61. #define MCCatalog    0x0100            /* Probably came from catalog */
  62. #define    MCFmtArg        (0x0001|MCCatalog)    /* Came from format string */
  63. #define MCUserArg    (0x0012|MCFree)        /* Came from program (e.g. %s) */
  64. #define MCDataArg    (0x0013|MCFree)        /* Came from data (e.g. %d) */
  65. #define MCMsgArg    (0x0004|MCCatalog)    /* Came from message catalog */
  66.  
  67. #define MCShortType    1
  68. #define MCLongType    2
  69. #define MCIntType    3
  70. #define MCLongFloatType    4
  71. #define MCFloatType    5
  72. #define MCStringType    6
  73. #define MCVoidPType    7
  74. #define MCShortPType    8
  75. #define MCLongPType    9
  76. #define MCIntPType    10
  77.  
  78. typedef struct {
  79.     int        type;
  80.     union {
  81.     short        shortV;
  82.     unsigned short    ushortV;
  83.     long        longV;
  84.     unsigned long    ulongV;
  85.     int        intV;
  86.     unsigned int    uintV;
  87. #ifdef LongFloat
  88.     long float    lfloatV;
  89. #endif
  90.     float        floatV;
  91.     char        *charPV;
  92.     int        *voidPV;
  93.     short        *shortPV;
  94.     long        *longPV;
  95.     int        *intPV;
  96.     } u;
  97. } MCTypesT;
  98.  
  99. #define MCSpaceFlag    0x01
  100. #define MCPlusFlag    0x02
  101. #define MCMinusFlag    0x04
  102. #define MCAltFlag    0x08
  103. #define MCZeroFlag    0x10
  104.  
  105.  
  106. typedef struct {
  107.     int        pos;
  108.     int        type;
  109.     char    c;
  110.     int        flag;
  111.     int        hasWidth;
  112.     int        widthPos;
  113.     int        width;
  114.     int        hasPrec;
  115.     int        precPos;
  116.     int        prec;
  117.     char    *data;
  118.     int        dataLen;
  119. } MCArgumentT;
  120.  
  121. typedef struct {
  122.     int        argType;
  123.     char    *data;
  124.     long    dataLen;
  125. } MCReplyT;
  126.  
  127. typedef struct {
  128.     MCArgumentT    *argList;
  129.     int        argCnt;
  130.     MCTypesT    *typeList;
  131.     int        typeCnt;
  132.     MCReplyT    *replyList;
  133.     int        replyCnt;
  134. } MCRockT;
  135.  
  136.  
  137. #define    MCPrintGet(start,rock)                              \
  138. {                                          \
  139.     va_list    vl;                                  \
  140.     int        i;                                  \
  141.     int     typeCnt = rock->typeCnt;                      \
  142.     MCTypesT    *typeList = rock->typeList;                      \
  143.                                           \
  144.     Va_start(vl, start);                              \
  145.     for (i = 0; i < typeCnt; ++i) {                          \
  146.     switch (typeList[i].type) {                          \
  147.       case MCShortType:                              \
  148.         typeList[i].u.shortV = va_arg(vl, short);                  \
  149.         break;                                  \
  150.       case MCLongType:                              \
  151.         typeList[i].u.longV = va_arg(vl, long);                  \
  152.         break;                                  \
  153.       case MCIntType:                              \
  154.         typeList[i].u.intV = va_arg(vl, int);                  \
  155.         break;                                  \
  156.       case MCLongFloatType:                              \
  157. /*#ifdef LongFloat                                  \
  158.         typeList[i].u.lfloatV = va_arg(vl, long float);              \
  159.         break;                                  \
  160. #endif*/                                      \
  161.       case MCFloatType:                              \
  162.         typeList[i].u.floatV = va_arg(vl, float);                  \
  163.         break;                                  \
  164.       case MCStringType:                              \
  165.         typeList[i].u.charPV = va_arg(vl, char *);                  \
  166.         break;                                  \
  167.       case MCVoidPType:                              \
  168.         typeList[i].u.voidPV = va_arg(vl, int *);                  \
  169.         break;                                  \
  170.       case MCShortPType:                              \
  171.         typeList[i].u.shortPV = va_arg(vl, short *);              \
  172.         break;                                  \
  173.       case MCLongPType:                              \
  174.         typeList[i].u.longPV = va_arg(vl, long *);                  \
  175.         break;                                  \
  176.       case MCIntPType:                              \
  177.         typeList[i].u.intPV = va_arg(vl, int *);                  \
  178.         break;                                  \
  179.     }                                      \
  180.     }                                          \
  181.     va_end(vl);                                      \
  182. }
  183.  
  184. extern MCRockT    *MCPrintInit();
  185. extern int    MCPrintParse();
  186. extern void    MCPrintFree();
  187.  
  188. #endif
  189.