|
|
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;
};
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.