Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.7 KiB

  1. /*****************************************************************************
  2. *
  3. * emit - Emit routines for MF3216
  4. *
  5. * Date: 7/17/91
  6. * Author: Jeffrey Newman (c-jeffn)
  7. *
  8. * 01-Feb-1992 -by- c-jeffn
  9. *
  10. * Major code cleanup from Code review 1.
  11. *
  12. * Copyright (c) 1991,92 Microsoft Corp
  13. *****************************************************************************/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. /*----------------------------------------------------------------------------
  17. * Emit (copy) nCount Bytes in pBuffer to the user supplied output buffer.
  18. *
  19. * If this is a size only request, send the bits to the bit-bucket and
  20. * just keep track of the size.
  21. *
  22. * Note: ERROR_BUFFER_OVERFLOW flag is set in pLocalDC if output buffer
  23. * is overrun.
  24. *---------------------------------------------------------------------------*/
  25. BOOL bEmit(PLOCALDC pLocalDC, PVOID pBuffer, DWORD nCount)
  26. {
  27. BOOL b ;
  28. UINT ulBytesEmitted ;
  29. b = TRUE ;
  30. // Test for a size only request.
  31. if (!(pLocalDC->flags & SIZE_ONLY))
  32. {
  33. ulBytesEmitted = pLocalDC->ulBytesEmitted ;
  34. if ((ulBytesEmitted + nCount) <= pLocalDC->cMf16Dest)
  35. {
  36. memcpy(&(pLocalDC->pMf16Bits[ulBytesEmitted]), pBuffer, nCount) ;
  37. b = TRUE ;
  38. }
  39. else
  40. {
  41. // Signal output buffer overflow error.
  42. // It can happen that we overflow the buffer if we fail the XOR
  43. // pass but don't fail the second pass. If the failure in the
  44. // XOR pass happens after we have reached the end of the buffer
  45. // the we will have a buffer overflow because it wasn't the
  46. // initial XOR pass that returned the size but the second pass
  47. // (The same thing could happen between the second pass and the
  48. // GDI pass) so we make it only a warning now.
  49. pLocalDC->flags |= ERR_BUFFER_OVERFLOW;
  50. b = FALSE ;
  51. WARNING(("MF3216: bEmit, (pLocalDC->ulBytesEmitted + nCount) > cMf16Dest \n"));
  52. }
  53. }
  54. // Update the local DC byte count
  55. pLocalDC->ulBytesEmitted += nCount ;
  56. return(b) ;
  57. }
  58. /*----------------------------------------------------------------------------
  59. * Update the max record size. Used to update the metafile header.
  60. *---------------------------------------------------------------------------*/
  61. VOID vUpdateMaxRecord(PLOCALDC pLocalDC, PMETARECORD pmr)
  62. {
  63. if (pLocalDC->ulMaxRecord < pmr->rdSize)
  64. pLocalDC->ulMaxRecord = pmr->rdSize;
  65. }