StringFuncs.h 3.6 KB

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