From: Andreas Reichel <[email protected]> To compare device paths it is necessary to be able to split of sub-paths from the right hand side. Implement a simple function for that purpose.
Signed-off-by: Andreas Reichel <[email protected]> --- include/utils.h | 1 + utils.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/utils.h b/include/utils.h index 285e45e..06721eb 100644 --- a/include/utils.h +++ b/include/utils.h @@ -29,6 +29,7 @@ typedef struct _VOLUME_DESC { typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE; +CHAR16 *StrRStrip(CHAR16 *input, CHAR16 delim); uint32_t calc_crc32(void *data, int32_t size); void __noreturn error_exit(CHAR16 *message, EFI_STATUS status); VOID sleep(int32_t sec); diff --git a/utils.c b/utils.c index 33e3a90..4f44a37 100644 --- a/utils.c +++ b/utils.c @@ -16,6 +16,29 @@ #include <bootguard.h> #include <utils.h> +CHAR16 *StrRStrip(CHAR16 *input, CHAR16 delim) +{ + CHAR16 *dst; + UINTN len; + + len = StrLen(input); + dst = mmalloc((len + 1) * 2); + if (!dst) { + return NULL; + } + + StrCpy(dst, input); + + for (UINTN i = len; i > 0; i--) + { + if (dst[i * 2] == delim) { + dst[i * 2] = L'\0'; + break; + } + } + return dst; +} + uint32_t calc_crc32(void *data, int32_t size) { uint32_t crc; -- 2.17.0 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20180525120108.31055-3-andreas.reichel.ext%40siemens.com. For more options, visit https://groups.google.com/d/optout.
