build: Remove dependencies on fmtlib

With C++23, we can replace fmt::format with std::format and fmt::print
with stdplus::print. This allows us to migrate to std::print once the
support is available.

Change-Id: I790901fb3b96d815275a3919e1fb90973189fc02
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/subprojects/ncsid/src/ncsi_state_machine.cpp b/subprojects/ncsid/src/ncsi_state_machine.cpp
index b2e0286..2ca4906 100644
--- a/subprojects/ncsid/src/ncsi_state_machine.cpp
+++ b/subprojects/ncsid/src/ncsi_state_machine.cpp
@@ -19,10 +19,11 @@
 #include "platforms/nemora/portable/ncsi_fsm.h"
 
 #include <arpa/inet.h>
-#include <fmt/printf.h>
 #include <netinet/ether.h>
 #include <unistd.h>
 
+#include <stdplus/print.hpp>
+
 #include <chrono>
 #include <cstdint>
 #include <cstdlib>
@@ -48,9 +49,10 @@
     {
         if (line_rep_count > 0)
         {
-            fmt::print(stderr, "... Repeated {} times ...\n", line_rep_count);
+            stdplus::println(stderr, "... Repeated {} times ...",
+                             line_rep_count);
         }
-        fmt::print(stderr, "{}", line);
+        stdplus::print(stderr, "{}", line);
         last_line = std::move(line);
         last_line_time = now;
         line_rep_count = 0;
@@ -61,7 +63,7 @@
     }
 }
 
-#define CPRINTF(...) do_log(fmt::sprintf(__VA_ARGS__))
+#define CPRINT(...) do_log(std::format(__VA_ARGS__))
 
 #ifdef NCSID_VERBOSE_LOGGING
 #define DEBUG_PRINTF printf
@@ -131,7 +133,7 @@
 
 StateMachine::~StateMachine()
 {
-    CPRINTF("[NCSI stopping]\n");
+    CPRINT("[NCSI stopping]\n");
 }
 
 size_t StateMachine::poll_l2_config()
@@ -200,7 +202,7 @@
                            NCSI_LINK_STATUS_UP;
         if (!link_up_ || new_link_up != *link_up_)
         {
-            CPRINTF("[NCSI link %s]\n", new_link_up ? "up" : "down");
+            CPRINT("[NCSI link {}]\n", new_link_up ? "up" : "down");
             link_up_ = new_link_up;
         }
     }
@@ -214,8 +216,8 @@
             bool new_hostless = ncsi_fsm_is_nic_hostless(&ncsi_state_);
             if (!hostless_ || new_hostless != *hostless_)
             {
-                CPRINTF("[NCSI nic %s]\n",
-                        new_hostless ? "hostless" : "hostfull");
+                CPRINT("[NCSI nic {}]\n",
+                       new_hostless ? "hostless" : "hostfull");
                 net_config_->set_nic_hostless(new_hostless);
                 hostless_ = new_hostless;
             }
@@ -241,27 +243,27 @@
             if (!ncsi_buf_.len)
             {
                 network_debug_.ncsi.rx_error.timeout_count++;
-                CPRINTF("[NCSI timeout in state %s]\n", state_string);
+                CPRINT("[NCSI timeout in state {}]\n", state_string);
             }
             else
             {
                 network_debug_.ncsi.rx_error.undersized_count++;
-                CPRINTF("[NCSI undersized response in state %s]\n",
-                        state_string);
+                CPRINT("[NCSI undersized response in state {}]\n",
+                       state_string);
             }
             break;
         case NCSI_RESPONSE_NACK:
             network_debug_.ncsi.rx_error.nack_count++;
-            CPRINTF(
-                "[NCSI nack in state %s. Response: 0x%04x Reason: 0x%04x]\n",
+            CPRINT(
+                "[NCSI nack in state {}. Response: {:#04x} Reason: {:#04x}]\n",
                 state_string, ntohs(response->response_code),
                 ntohs(response->reason_code));
             break;
         case NCSI_RESPONSE_UNEXPECTED_TYPE:
             network_debug_.ncsi.rx_error.unexpected_type_count++;
-            CPRINTF("[NCSI unexpected response in state %s. Response type: "
-                    "0x%02x]\n",
-                    state_string, response->hdr.control_packet_type);
+            CPRINT(
+                "[NCSI unexpected response in state {}. Response type: {:#02x}]\n",
+                state_string, response->hdr.control_packet_type);
             break;
         case NCSI_RESPONSE_UNEXPECTED_SIZE:
         {
@@ -281,24 +283,24 @@
                     response->hdr.control_packet_type & (~NCSI_RESPONSE));
             }
             network_debug_.ncsi.rx_error.unexpected_size_count++;
-            CPRINTF("[NCSI unexpected response size in state %s."
-                    " Expected %d]\n",
-                    state_string, expected_size);
+            CPRINT("[NCSI unexpected response size in state {}."
+                   " Expected {}]\n",
+                   state_string, expected_size);
         }
         break;
         case NCSI_RESPONSE_OEM_FORMAT_ERROR:
             network_debug_.ncsi.rx_error.unexpected_type_count++;
-            CPRINTF("[NCSI OEM format error]\n");
+            CPRINT("[NCSI OEM format error]\n");
             break;
         case NCSI_RESPONSE_UNEXPECTED_PARAMS:
-            CPRINTF("[NCSI OEM Filter MAC or TCP/IP Config Mismatch]\n");
+            CPRINT("[NCSI OEM Filter MAC or TCP/IP Config Mismatch]\n");
             break;
         default:
             /* NCSI_RESPONSE_ACK and NCSI_RESPONSE_NONE are not errors and need
              * not be handled here, so this branch is just to complete the
              * switch.
              */
-            CPRINTF("[NCSI OK]\n");
+            CPRINT("[NCSI OK]\n");
             break;
     }
 }
@@ -343,10 +345,10 @@
 {
     if (!net_config_ || !sock_io_)
     {
-        CPRINTF("StateMachine configuration incomplete: "
-                "net_config_: <%p>, sock_io_: <%p>",
-                reinterpret_cast<void*>(net_config_),
-                reinterpret_cast<void*>(sock_io_));
+        CPRINT("StateMachine configuration incomplete: "
+               "net_config_: <{}>, sock_io_: <{}>",
+               reinterpret_cast<void*>(net_config_),
+               reinterpret_cast<void*>(sock_io_));
         return;
     }