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 / mcprt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-23  |  3.2 KB  |  122 lines

  1.  
  2. /***********************************************************
  3. Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its
  8. documentation for any purpose and without fee is hereby granted,
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in
  11. supporting documentation, and that Alfalfa's name not be used in
  12. advertising or publicity pertaining to distribution of the software
  13. without specific, written prior permission.
  14.  
  15. ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. If you make any modifications, bugfixes or other changes to this software
  24. we'd appreciate it if you could send a copy to us so we can keep things
  25. up-to-date.  Many thanks.
  26.                 Kee Hinckley
  27.                 Alfalfa Software, Inc.
  28.                 267 Allston St., #3
  29.                 Cambridge, MA 02139  USA
  30.                 nazgul@alfalfa.com
  31.     
  32. ******************************************************************/
  33.  
  34. /* Edit History
  35.  
  36. 01/18/91   3 hamilton    #if not rescanned
  37. 01/12/91   1 schulert    conditionally use prototypes
  38.             rework to use either varargs or stdargs
  39. 11/03/90   2 hamilton    Alphalpha->Alfalfa & OmegaMail->Poste
  40. 08/10/90   1 nazgul    printf, sprintf and fprintf
  41. */
  42.  
  43. #include <stdio.h>
  44.  
  45. #include "mcprt.h"
  46. #include "mcprtlib.h"
  47.  
  48. int    MCprintf(
  49. #if defined(__STDC__) || defined(__cplusplus)
  50.         char *fmt, ...)
  51. #else
  52.         fmt, va_alist)
  53. char *fmt;
  54. va_dcl
  55. #endif
  56. {
  57.     MCRockT    *rock;
  58.     int        len, i;
  59.     
  60.     if ((rock = MCPrintInit(fmt)) == NULL) return -1;
  61.     MCPrintGet(fmt, rock);
  62.     if ((len = MCPrintParse(rock)) < 0) return -1;
  63.  
  64.     for (i = 0; i < rock->replyCnt; ++i)
  65.       fwrite(rock->replyList[i].data, 1, rock->replyList[i].dataLen, stdout);
  66.     MCPrintFree(rock);
  67.  
  68.     return len;
  69. }
  70.  
  71. int    MCfprintf(
  72. #if defined(__STDC__) || defined(__cplusplus)
  73.         FILE *fptr, char *fmt, ...)
  74. #else
  75.         fptr, fmt, va_alist)
  76. FILE *fptr;
  77. char *fmt;
  78. va_dcl
  79. #endif
  80. {
  81.     MCRockT    *rock;
  82.     int        len, i;
  83.     
  84.     if ((rock = MCPrintInit(fmt)) == NULL) return -1;
  85.     MCPrintGet(fmt, rock);
  86.     if ((len = MCPrintParse(rock)) < 0) return -1;
  87.  
  88.     for (i = 0; i < rock->replyCnt; ++i)
  89.       fwrite(rock->replyList[i].data, 1, rock->replyList[i].dataLen, fptr);
  90.     MCPrintFree(rock);
  91.  
  92.     return len;
  93. }
  94.  
  95. int    MCsprintf(
  96. #if defined(__STDC__) || defined(__cplusplus)
  97.         char *cptr, char *fmt, ...)
  98. #else
  99.         cptr, fmt, va_alist)
  100. char *cptr;
  101. char *fmt;
  102. va_dcl
  103. #endif
  104. {
  105.     MCRockT    *rock;
  106.     int        len, i;
  107.     
  108.     if ((rock = MCPrintInit(fmt)) == NULL) return -1;
  109.     MCPrintGet(fmt, rock);
  110.     if ((len = MCPrintParse(rock)) < 0) return -1;
  111.  
  112.     for (i = 0; i < rock->replyCnt; ++i) {
  113.     bcopy(rock->replyList[i].data, cptr, rock->replyList[i].dataLen);
  114.     cptr += rock->replyList[i].dataLen;
  115.     }
  116.     *cptr = '\0';
  117.  
  118.     MCPrintFree(rock);
  119.  
  120.     return len;
  121. }
  122.