StringFuncs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /** @file
  2. String routines implementation
  3. Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _EFI_STRING_FUNCS_H
  7. #define _EFI_STRING_FUNCS_H
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <Common/UefiBaseTypes.h>
  11. //
  12. // Common data structures
  13. //
  14. typedef struct {
  15. UINTN Count;
  16. //
  17. // Actually this array can be 0 or more items (based on Count)
  18. //
  19. CHAR8* Strings[1];
  20. } STRING_LIST;
  21. //
  22. // Functions declarations
  23. //
  24. CHAR8*
  25. CloneString (
  26. IN CHAR8 *String
  27. )
  28. ;
  29. /**
  30. Routine Description:
  31. Allocates a new string and copies 'String' to clone it
  32. Arguments:
  33. String The string to clone
  34. Returns:
  35. CHAR8* - NULL if there are not enough resources
  36. **/
  37. EFI_STATUS
  38. StripInfDscStringInPlace (
  39. IN CHAR8 *String
  40. )
  41. ;
  42. /**
  43. Routine Description:
  44. Remove all comments, leading and trailing whitespace from the string.
  45. Arguments:
  46. String The string to 'strip'
  47. Returns:
  48. EFI_STATUS
  49. **/
  50. STRING_LIST*
  51. SplitStringByWhitespace (
  52. IN CHAR8 *String
  53. )
  54. ;
  55. /**
  56. Routine Description:
  57. Creates and returns a 'split' STRING_LIST by splitting the string
  58. on whitespace boundaries.
  59. Arguments:
  60. String The string to 'split'
  61. Returns:
  62. EFI_STATUS
  63. **/
  64. STRING_LIST*
  65. NewStringList (
  66. )
  67. ;
  68. /**
  69. Routine Description:
  70. Creates a new STRING_LIST with 0 strings.
  71. Returns:
  72. STRING_LIST* - Null if there is not enough resources to create the object.
  73. **/
  74. EFI_STATUS
  75. AppendCopyOfStringToList (
  76. IN OUT STRING_LIST **StringList,
  77. IN CHAR8 *String
  78. )
  79. ;
  80. /**
  81. Routine Description:
  82. Adds String to StringList. A new copy of String is made before it is
  83. added to StringList.
  84. Returns:
  85. EFI_STATUS
  86. **/
  87. EFI_STATUS
  88. RemoveLastStringFromList (
  89. IN STRING_LIST *StringList
  90. )
  91. ;
  92. /**
  93. Routine Description:
  94. Removes the last string from StringList and frees the memory associated
  95. with it.
  96. Arguments:
  97. StringList The string list to remove the string from
  98. Returns:
  99. EFI_STATUS
  100. **/
  101. STRING_LIST*
  102. AllocateStringListStruct (
  103. IN UINTN StringCount
  104. )
  105. ;
  106. /**
  107. Routine Description:
  108. Allocates a STRING_LIST structure that can store StringCount strings.
  109. Arguments:
  110. StringCount The number of strings that need to be stored
  111. Returns:
  112. EFI_STATUS
  113. **/
  114. VOID
  115. FreeStringList (
  116. IN STRING_LIST *StringList
  117. )
  118. ;
  119. /**
  120. Routine Description:
  121. Frees all memory associated with StringList.
  122. Arguments:
  123. StringList The string list to free
  124. Returns:
  125. EFI_STATUS
  126. **/
  127. CHAR8*
  128. StringListToString (
  129. IN STRING_LIST *StringList
  130. )
  131. ;
  132. /**
  133. Routine Description:
  134. Generates a string that represents the STRING_LIST
  135. Arguments:
  136. StringList The string list to convert to a string
  137. Returns:
  138. CHAR8* - The string list represented with a single string. The returned
  139. string must be freed by the caller.
  140. **/
  141. VOID
  142. PrintStringList (
  143. IN STRING_LIST *StringList
  144. )
  145. ;
  146. /**
  147. Routine Description:
  148. Prints out the string list
  149. Arguments:
  150. StringList The string list to print
  151. **/
  152. #endif