/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* fbconsole - fallback console
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include <signal.h>
#include <stropts.h>
#include <termios.h>
#include <sys/strredir.h>
/*
* Default settings to use if they can't actually be obtained from a
* descriptor relevant to the application.
*
* XXX: These settings shouldn't be used unless absolutely necessary, since
* they're almost certain to get out of sync with the kernel's defaults
* (which is what they're intended to be).
*/
/* control characters */
CINTR, /* VINTR */
CQUIT, /* VQUIT */
CERASE, /* VERASE */
CKILL, /* VKILL */
CEOT, /* VEOF */
CEOL, /* VEOL */
CEOL2, /* VEOL2 */
CNUL, /* VSWTCH */
CSTART, /* VSTART */
CSTOP, /* VSTOP */
CSUSP, /* VSUSP */
CDSUSP, /* VDSUSP */
CRPRNT, /* VRPRNT */
CFLUSH, /* VDISCARD */
CWERASE, /* VWERASE */
CLNEXT, /* VLNEXT */
};
#ifdef NOTDEF
/*
* OpenConsole
* Returns a file descriptor which has had the console redirected to it
*
* This version (unused) opens a pipe and redirects the console to it.
*/
static int
OpenConsole(void)
{
int fdcons;
perror("pipe");
exit(1);
}
perror("open");
exit(1);
}
exit(1);
}
return fds[1];
}
#endif /* NOTDEF */
/*
* OpenConsole
*
* console output to it. Returns the master end of the pty.
*/
static int
OpenConsole(void)
{
int console;
int master;
int slave;
char *slavename;
exit(1);
}
exit(1);
}
exit(1);
}
exit(1);
}
exit(1);
}
#ifdef DEBUG
#endif
perror("fbconsole: open slave");
exit(1);
}
perror("fbconsole: push ptem");
exit(1);
}
perror("fbconsole: push ldterm");
exit(1);
}
/*
* Propagate tty settings from the real console to the new console.
* If the erase character is zero, apply default settings to the new
* console. If the erase character is nonzero, leave most of the
* settings intact and apply default values only to the modes and to
* the EOF and EOL character. (Why apply defaults for EOF and EOL?)
*
* Code originally taken from XView, lib/libxview/ttysw/tty_gtty.c
*/
perror("fbconsole: tcgetattr");
exit(1);
}
} else {
}
perror("fbconsole: tcsetattr");
exit(1);
}
/* redirect console output into the slave side */
perror("fbconsole: ioctl SRIOCSREDIR");
exit(1);
}
return master;
}
/*
* OpenLog
* Opens the console log file; returns a file descriptor
*/
static FILE *
const char *dpyName,
char *path)
{
const char *tmpName;
int tmpFd;
}
tmpFd = -1;
} else {
}
} else {
LogPath[0] = '\0';
return stderr;
}
}
#ifdef DEBUG
#endif
"fbconsole: couldn't open console log file '%s'\n",path);
exit(1);
}
return log;
}
/*
* CloseLog
*/
static void
CloseLog(void)
{
if (LogPath[0] == '\0')
return;
perror("unlink");
}
/*
* CleanupAndExit
* Closes log file and exits
*/
static void
CleanupAndExit(void)
{
CloseLog();
exit(0);
}
/*
* SignalHandler
* The signal handler for SIGINT and SIGTERM.
*/
/*ARGSUSED*/
void
{
}
/*
* DisplayErrorHandler
* X I/O error handler.
*/
/*ARGSUSED*/
int
{
return 0;
}
/*
* LogConsole
* Reads a console message and writes it to the console log file
*/
static void
int console,
{
int rcount;
if (rcount == -1)
return;
}
/*
* InputLoop
* Waits for input from the console message pipe or the xserver.
* On input from the console - logs it to the console log file.
* On any input (or EOF) from the xserver, exits
*/
static void
int console,
{
#define CONSOLE_FD 0
fdcount++;
}
}
}
}
}
/*
* Usage
* Prints a usage message
*/
static void
Usage(void)
{
exit(1);
}
/*
* main
*/
int
{
int console;
int opt;
switch (opt) {
case 'd':
break;
case 'n':
break;
case 'f':
break;
case '?':
Usage();
break;
}
}
if (noDisplay) {
} else {
"Couldn't open display connection %s\n",
exit(1);
}
(void) XSetIOErrorHandler(DisplayErrorHandler);
}
console = OpenConsole();
return(0);
}