Clipboard.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /** @file
  2. Functions to deal with Clip Board
  3. Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "HexEditor.h"
  7. typedef struct {
  8. UINT8 *Buffer;
  9. UINTN Size;
  10. } HEFI_EDITOR_CLIPBOARD;
  11. HEFI_EDITOR_CLIPBOARD HClipBoard;
  12. //
  13. // for basic initialization of HClipBoard
  14. //
  15. HEFI_EDITOR_CLIPBOARD HClipBoardConst = {
  16. NULL,
  17. 0
  18. };
  19. /**
  20. Initialization function for HDiskImage.
  21. @param[in] EFI_SUCCESS The operation was successful.
  22. @param[in] EFI_LOAD_ERROR A load error occurred.
  23. **/
  24. EFI_STATUS
  25. HClipBoardInit (
  26. VOID
  27. )
  28. {
  29. //
  30. // basiclly initialize the HDiskImage
  31. //
  32. CopyMem (&HClipBoard, &HClipBoardConst, sizeof (HClipBoard));
  33. return EFI_SUCCESS;
  34. }
  35. /**
  36. Initialization function for HDiskImage.
  37. @param[in] EFI_SUCCESS The operation was successful.
  38. @param[in] EFI_LOAD_ERROR A load error occurred.
  39. **/
  40. EFI_STATUS
  41. HClipBoardCleanup (
  42. VOID
  43. )
  44. {
  45. SHELL_FREE_NON_NULL (HClipBoard.Buffer);
  46. return EFI_SUCCESS;
  47. }
  48. /**
  49. Set a buffer into the clipboard.
  50. @param[in] Buffer The buffer to add to the clipboard.
  51. @param[in] Size The size of Buffer in bytes.
  52. @retval EFI_SUCCESS The operation was successful.
  53. **/
  54. EFI_STATUS
  55. HClipBoardSet (
  56. IN UINT8 *Buffer,
  57. IN UINTN Size
  58. )
  59. {
  60. //
  61. // free the old clipboard buffer
  62. // and set new clipboard buffer
  63. //
  64. SHELL_FREE_NON_NULL (HClipBoard.Buffer);
  65. HClipBoard.Buffer = Buffer;
  66. HClipBoard.Size = Size;
  67. return EFI_SUCCESS;
  68. }
  69. /**
  70. Get a buffer from the clipboard.
  71. @param[out] Buffer The pointer to the buffer to add to the clipboard.
  72. @return the size of the buffer.
  73. **/
  74. UINTN
  75. HClipBoardGet (
  76. OUT UINT8 **Buffer
  77. )
  78. {
  79. //
  80. // return the clipboard buffer
  81. //
  82. *Buffer = HClipBoard.Buffer;
  83. return HClipBoard.Size;
  84. }