--- nono/debugger/console.h 2026/04/29 17:04:30 1.1.1.1 +++ nono/debugger/console.h 2026/04/29 17:04:40 1.1.1.3 @@ -1,6 +1,7 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once @@ -19,7 +20,8 @@ class Console // 初期化 virtual bool Init() = 0; - virtual bool Open() = 0; + // 受け付ける + virtual bool Accept() = 0; // EditLine を初期化する void InitEditLine(const char *prompt); @@ -38,7 +40,8 @@ class Console bool Gets(std::string&); // 受信データがあれば正、なければ 0 を返す。エラーなら負数を返す。 - int Poll(); + // msec はタイムアウト値の指定。0 ならポーリング。(タイムアウトなしは-1) + int Poll(int msec = 0); protected: void FDOpen(); @@ -46,17 +49,17 @@ class Console struct { int fd; FILE *file; - } inp, out; + } inp {}, out {}; // Editline を使うかどうかのフラグ。継承側がセットする。 // 今のところ TCP console では動かないのでこんなことになっている。 - bool use_editline = false; + bool use_editline {}; // Editline - const char *prompt = NULL; + const char *prompt {}; #if defined(HAVE_HISTEDIT_H) - EditLine *el = NULL; - History *hist = NULL; + EditLine *el {}; + History *hist {}; HistEvent hev {}; #endif @@ -74,29 +77,29 @@ class ConsoleStdio { public: ConsoleStdio(); - virtual ~ConsoleStdio(); + ~ConsoleStdio() override; - bool Init(); - bool Open(); - void Close(); + bool Init() override; + bool Accept() override; + void Close() override; }; // TCP コンソール class ConsoleTCP : public Console { - typedef Console inherited; + using inherited = Console; public: ConsoleTCP(); - virtual ~ConsoleTCP(); + ~ConsoleTCP() override; - bool Init(); - bool Open(); - void Close(); + bool Init() override; + bool Accept() override; + void Close() override; private: - int ls = 0; - int sock = 0; - struct addrinfo *res = NULL; - struct addrinfo *ai = NULL; + int ls {}; + int sock {}; + struct addrinfo *res {}; + struct addrinfo *ai {}; };