home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / elm-2.4-pl20.tar.Z / elm-2.4-pl20.tar / lib / mcprt.c < prev    next >
C/C++ Source or Header  |  1992-10-03  |  3KB  |  109 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.  
  44. #include <stdio.h>
  45. #include "defs.h"
  46.  
  47. #include "mcprt.h"
  48. #include "mcprtlib.h"
  49.  
  50. int    MCprintf(fmt, va_alist)
  51. char *fmt;
  52. va_dcl
  53. {
  54.     MCRockT    *rock;
  55.     int        len, i;
  56.     
  57.     if ((rock = MCPrintInit(fmt)) == NULL) return -1;
  58.     MCPrintGet(fmt, rock);
  59.     if ((len = MCPrintParse(rock)) < 0) return -1;
  60.  
  61.     for (i = 0; i < rock->replyCnt; ++i)
  62.       fwrite(rock->replyList[i].data, 1, rock->replyList[i].dataLen, stdout);
  63.     MCPrintFree(rock);
  64.  
  65.     return len;
  66. }
  67.  
  68. int    MCfprintf(fptr, fmt, va_alist)
  69. FILE *fptr;
  70. char *fmt;
  71. va_dcl
  72. {
  73.     MCRockT    *rock;
  74.     int        len, i;
  75.     
  76.     if ((rock = MCPrintInit(fmt)) == NULL) return -1;
  77.     MCPrintGet(fmt, rock);
  78.     if ((len = MCPrintParse(rock)) < 0) return -1;
  79.  
  80.     for (i = 0; i < rock->replyCnt; ++i)
  81.       fwrite(rock->replyList[i].data, 1, rock->replyList[i].dataLen, fptr);
  82.     MCPrintFree(rock);
  83.  
  84.     return len;
  85. }
  86.  
  87. int    MCsprintf(cptr, fmt, va_alist)
  88. char *cptr;
  89. char *fmt;
  90. va_dcl
  91. {
  92.     MCRockT    *rock;
  93.     int        len, i;
  94.     
  95.     if ((rock = MCPrintInit(fmt)) == NULL) return -1;
  96.     MCPrintGet(fmt, rock);
  97.     if ((len = MCPrintParse(rock)) < 0) return -1;
  98.  
  99.     for (i = 0; i < rock->replyCnt; ++i) {
  100.     bcopy(rock->replyList[i].data, cptr, rock->replyList[i].dataLen);
  101.     cptr += rock->replyList[i].dataLen;
  102.     }
  103.     *cptr = '\0';
  104.  
  105.     MCPrintFree(rock);
  106.  
  107.     return len;
  108. }
  109.