/* * This file is part of Jehanne. * * Copyright (C) 2015-2018 Giacomo Tesio * * Jehanne is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License. * * Jehanne is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jehanne. If not, see . */ #define IODATASZ 8192 /* do not change this, or convM2S wont work! */ enum { KeyboardBufferSize = 32, ScreenBufferSize = KeyboardBufferSize*8, }; /* Read from the first fd, do its own work, and write to the second */ typedef void (*StreamFilter)(int, int); extern int systemwide; /* all the system depend on this console: * - allow multiple attach * - never end fsserve */ extern int blind; /* no feedback for input, disables rawmode */ extern int linecontrol; extern int crnl; /* turn \n into \r\n to output device */ extern int posix; /* Qcons name is "tty" instead of "cons" */ extern int debugging; extern void enabledebug(const char *); extern void debug(const char *, ...); typedef struct Buffer Buffer; struct Buffer { uint32_t size; uint32_t written; uint32_t read; uint32_t ctrld; /* index of first byte after a ^D (input only) */ int newlines; /* number of newlines (input only) */ int linewidth; void (*add)(char, Buffer *); char *data; }; extern Buffer* balloc(uint32_t); extern uint32_t bwrite(Buffer *, char *, uint32_t); extern char *bread(Buffer *, uint32_t *); extern char *breadln(Buffer *b, uint32_t *length); extern int blineready(Buffer *); #define bempty(b) (b->read == b->written && b->ctrld == b->size) #define bspace(b) (b->size - b->written) #define bpending(b) (b->written - b->read) extern int servecons(StreamFilter, StreamFilter, int*); extern void post(char *srv, int fd); extern int fsinit(int *, int *); extern void fsserve(int); extern void passthrough(int, int); extern void writecga(int, int); extern void readkeyboard(int, int);