瀏覽代碼

Implement VSPrint function, prints a formatted unicode string to a buffer.

    Signed-off-by: Jeremy Compostella <jeremy.compostella@gmail.com>
    Signed-off-by: Nigel Croxon <nigel.croxon@hp.com>
Nigel Croxon 11 年之前
父節點
當前提交
107c806352
共有 2 個文件被更改,包括 60 次插入7 次删除
  1. 15 0
      gnu-efi-3.0/inc/efilib.h
  2. 45 7
      gnu-efi-3.0/lib/print.c

+ 15 - 0
gnu-efi-3.0/inc/efilib.h

@@ -24,6 +24,7 @@ Revision History
 #include "efilibplat.h"
 #include "efilink.h"
 #include "efirtlib.h"
+#include "efistdarg.h"
 #include "pci22.h"
 #include "libsmbios.h"
 
@@ -391,6 +392,12 @@ Print (
     ...
     );
 
+UINTN
+VPrint (
+    IN CHAR16   *fmt,
+    va_list     args
+    );
+
 UINTN
 SPrint (
     OUT CHAR16  *Str,
@@ -399,6 +406,14 @@ SPrint (
     ...
     );
 
+UINTN
+VSPrint (
+    OUT CHAR16  *Str,
+    IN UINTN    StrSize,
+    IN CHAR16   *fmt,
+    va_list     args
+    );
+
 CHAR16 *
 PoolPrint (
     IN CHAR16           *fmt,

+ 45 - 7
gnu-efi-3.0/lib/print.c

@@ -421,17 +421,17 @@ _PoolCatPrint (
 
 
 UINTN
-SPrint (
+VSPrint (
     OUT CHAR16  *Str,
     IN UINTN    StrSize,
     IN CHAR16   *fmt,
-    ...
+    va_list     args
     )
 /*++
 
 Routine Description:
 
-    Prints a formatted unicode string to a buffer
+    Prints a formatted unicode string to a buffer using a va_list
 
 Arguments:
 
@@ -442,6 +442,9 @@ Arguments:
 
     fmt         - The format string
 
+    args        - va_list
+
+
 Returns:
 
     String length returned in buffer
@@ -449,19 +452,54 @@ Returns:
 --*/
 {
     POOL_PRINT          spc;
-    va_list             args;
-
 
-    va_start (args, fmt);
     spc.str    = Str;
     spc.maxlen = StrSize / sizeof(CHAR16) - 1;
     spc.len    = 0;
 
     _PoolCatPrint (fmt, args, &spc, _SPrint);
-    va_end (args);
+
     return spc.len;
 }
 
+UINTN
+SPrint (
+    OUT CHAR16  *Str,
+    IN UINTN    StrSize,
+    IN CHAR16   *fmt,
+    ...
+    )
+/*++
+
+Routine Description:
+
+    Prints a formatted unicode string to a buffer
+
+Arguments:
+
+    Str         - Output buffer to print the formatted string into
+
+    StrSize     - Size of Str.  String is truncated to this size.
+                  A size of 0 means there is no limit
+
+    fmt         - The format string
+
+Returns:
+
+    String length returned in buffer
+
+--*/
+{
+    va_list          args;
+    UINTN            len;
+
+    va_start (args, fmt);
+    len = VSPrint(Str, StrSize, fmt, args);
+    va_end (args);
+
+    return len;
+}
+
 
 CHAR16 *
 PoolPrint (