File:  [Isaki's NoNo m68k/m88k emulator] / nono / debugger / consio.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:04:28 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v002, v001, HEAD
nono 0.0.1

//
// nono
// Copyright (C) 2019 [email protected]
//

#pragma once

// コンソール(?)
class Consio
{
 public:
	Consio() { }
	virtual ~Consio() { }

	virtual bool Init() = 0;

	virtual bool Open() = 0;
	virtual void Close() = 0;
	virtual void Print(const char *fmt, ...) __printflike(2, 3) = 0;
	virtual void Flush() = 0;

	// 1文字読み込む。
	// 戻り値は正なら読み込んだバイト。0 なら EOF。-1 ならエラー。
	virtual int  GetChar() = 0;

	// 1行読み込む。
	// 戻り値は読み込んだバイト数。0 なら EOF。-1 ならエラー。
	// バッファは \0 で終端してある。
	virtual int  Gets(char *, int) = 0;

	// 受信データがあれば正、なければ 0 を返す。エラーなら負数を返す。
	virtual int  Poll() = 0;
};

class ConsioTCP
	: public Consio
{
 public:
	ConsioTCP();
	virtual ~ConsioTCP();

	bool Init();
	bool Open();
	void Close();
	void Print(const char *fmt, ...) __printflike(2, 3);
	void Flush();
	int  GetChar();
	int  Gets(char *, int);
	int  Poll();

 private:
	int ls = 0;
	int sock = 0;
	struct addrinfo *res = NULL;
	struct addrinfo *ai = NULL;
};

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.