VOID EfiStrnCat ( IN CHAR16 *Dest, IN CHAR16 *Src, IN UINTN Length ) /*++ Routine Description: Concatinate Source on the end of Destination Arguments: Dst Destination string Src Source string Length Length of destination string Returns: --*/ { EfiStrnCpy (Dest + EfiStrLen (Dest), Src, Length); }
VOID AlignmentItem ( IN CHAR16 *ControllerHandleName, IN CHAR16 *PrefixString, IN OUT CHAR16 **NewString ) /*++ Routine Description: Do controller item string swap and alignment if needed. The alignment is the length of PrefixString. Because controller device path is too long sometime and cannot be presented in one line, and the browser automatic swap will break the necessary alignment, so do some additional process for the problem. Arguments: ControllerHandleName - a pointer to the controller real device path string PrefixString- a pointer to the prefix string NewString - a pointer to the string which will be presented by the browser Returns: None --*/ { CHAR16 *PadString; UINTN PtrIndex; UINTN IndexOffset; UINTN Width; CHAR16 *NewStringSwapped; UINTN SwapLineNum; UINTN SwapLine; // // Register the device name string and create item in set options page // *NewString = EfiLibAllocateZeroPool (EfiStrSize (ControllerHandleName) + EfiStrSize (PrefixString)); EfiStrCat (*NewString, PrefixString); EfiStrCat (*NewString, ControllerHandleName); // // Add pad chars into the string for string swap in set options page to solve following two issue: // Issue1: Our form browser will do the string swap according to the spaces in the string, so // if a string is too long and without space in it, the string position will be ugly. // The driver need add some spaces to control the swap in the long and no space string. // Issue2: If browser find a space to do swap, it will not show any other space directly followed it in swap position. // So if you want to use the space to do the alignment in swapped new line, you need add another char(e.g '.') in it. // e.g. if the item max lenth is 5, then the following string need add some space and '.' to get right presentation // '12345678901234567890' --------> ' 12345 . 67890 . 12345 . 67890' , and presentation is below // | 12345 // |. 67890 // |. 12345 // |. 67890 // if ((EfiStrLen (*NewString)/SWAP_LENGTH > 0) && (EfiStrLen (PrefixString) > 0)) { // // Prepare the pad string according to the PrefixString length // the pad string is string of ' ', except of the NO2 charater which is '.' // PadString = EfiLibAllocateZeroPool (EfiStrSize (PrefixString) + 2); for (PtrIndex = 0; PtrIndex < (EfiStrLen (PrefixString) + 1); PtrIndex++) { PadString[PtrIndex] = ' '; } PadString[1] = '.'; Width = SWAP_LENGTH - EfiStrLen (PrefixString); SwapLineNum = EfiStrLen (ControllerHandleName)/Width; NewStringSwapped = EfiLibAllocateZeroPool (EfiStrSize (ControllerHandleName) + EfiStrSize (PrefixString) + SwapLineNum * EfiStrSize (PadString)); ASSERT (NewStringSwapped != NULL); IndexOffset = 0; EfiStrCpy (NewStringSwapped, PrefixString); IndexOffset += EfiStrLen (PrefixString); for (SwapLine = 0; SwapLine < SwapLineNum; SwapLine++) { EfiStrnCpy (&NewStringSwapped[IndexOffset], &ControllerHandleName[SwapLine * Width], Width ); IndexOffset += Width; EfiStrnCpy (&NewStringSwapped[IndexOffset], PadString, EfiStrLen (PadString) ); IndexOffset += EfiStrLen (PadString); } EfiStrCat (NewStringSwapped, &ControllerHandleName[SwapLine * Width]); gBS->FreePool (PadString); gBS->FreePool (*NewString); *NewString = NewStringSwapped; } return; }