www.pudn.com > Demo C.rar > stdio_rd.c
/*
* Standard I/O redirection
*
* Author: Aaron Kunze, aaron.kunze@intel.com
*
* $Id: stdio_rd.c,v 1.1 1999/11/30 22:28:07 borkhuis Exp $
*
*/
#define TO_SYSTEM_MONITOR 1
#define TO_TARGET_SHELL 2
#define TO_COMM3 3
void RedirectStandardIO(IO_DIRECTION direction)
{
int op;
switch (direction)
{
case TO_SYSTEM_MONITOR:
op = open("/pcConsole/0", O_RDWR | O_CREAT, 0);
if (op == ERROR)
{
puts("Error Redirecting Output to pcConsole");
}
else
{
ioGlobalStdSet(STD_IN, op);
ioGlobalStdSet(STD_OUT, op);
ioGlobalStdSet(STD_ERR, op);
}
break;
case TO_TARGET_SHELL:
op = open("/vio/0", O_RDWR | O_CREAT, 0);
if (op == ERROR)
{
puts("Error Redirecting Output to Target Shell");
}
else
{
ioGlobalStdSet(STD_OUT, op);
ioGlobalStdSet(STD_ERR, op);
logFdSet(op);
}
break;
case TO_COMM3:
op = open("/tyCo/2", O_RDWR | O_CREAT, 0);
if (op == ERROR)
{
puts("Error Redirecting Output to comm 3");
}
else
{
ioGlobalStdSet(STD_IN, op);
ioGlobalStdSet(STD_OUT, op);
ioGlobalStdSet(STD_ERR, op);
}
break;
}; // end of switch
}