228 lines
6.1 KiB
C
228 lines
6.1 KiB
C
/*
|
|
******************************************************************************
|
|
* INTERPEAK SOURCE FILE
|
|
*
|
|
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipcom_stdio.c,v $ $Revision: 1.15.164.1 $
|
|
* $Source: /home/interpeak/CVSRoot/ipcom/port/src/ipcom_stdio.c,v $
|
|
* $Author: svc-cmnet $
|
|
* $State: Exp $ $Locker: $
|
|
*
|
|
* INTERPEAK_COPYRIGHT_STRING
|
|
* Design and implementation by Lennart Bang <lob@interpeak.se>
|
|
******************************************************************************
|
|
*/
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include "ipcom_config.h"
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#if IPCOM_USE_SHELL == IPCOM_SHELL_NATIVE || defined(IP_PORT_VXWORKS)
|
|
#include <stdio.h>
|
|
#else
|
|
#define IPCOM_USE_CLIB_PROTO
|
|
#endif
|
|
|
|
#include "ipcom_clib.h"
|
|
#include "ipcom_type.h"
|
|
#if IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
|
#include "ipcom_os.h"
|
|
#include "ipcom_sock.h"
|
|
#endif
|
|
|
|
#if IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
|
#include "ipcom_shell.h"
|
|
#endif
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 6 EXTERN PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 7 LOCAL PROTOTYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 8 DATA
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 9 STATIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
* These file pointers do not need to point to a valid file object. We
|
|
* only need to recognize them
|
|
*/
|
|
IP_STATIC IP_FILE* ipcom_stdin_file = (IP_FILE *) &ipcom_stdin_file;
|
|
IP_STATIC IP_FILE* ipcom_stdout_file = (IP_FILE *) &ipcom_stdout_file;
|
|
IP_STATIC IP_FILE* ipcom_stderr_file = (IP_FILE *) &ipcom_stderr_file;
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_shell_stdio
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
#if !defined(IP_PORT_VXWORKS) && IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
|
IP_STATIC IP_FILE *
|
|
ipcom_shell_stdio(int fd)
|
|
{
|
|
Ipcom_proc *proc;
|
|
|
|
proc = ipcom_proc_self();
|
|
if(proc && (proc->shell_fd != IP_INVALID_SOCKET))
|
|
{
|
|
switch (fd)
|
|
{
|
|
case 0: /* stdin */
|
|
return ipcom_stdin_file;
|
|
case 1: /* stdout */
|
|
return ipcom_stdout_file;
|
|
case 2: /* stderr */
|
|
return ipcom_stderr_file;
|
|
}
|
|
}
|
|
return IP_NULL;
|
|
}
|
|
#endif
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 10 GLOBAL FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 11 PUBLIC FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_stdout
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_PUBLIC IP_FILE *
|
|
ipcom_stdout(void)
|
|
{
|
|
#ifdef IP_PORT_VXWORKS
|
|
return (IP_FILE *)stdout;
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
|
return ipcom_shell_stdio(1);
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
|
return IP_FILE_STDOUT;
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
|
return (IP_FILE *)IP_NULL;
|
|
#else
|
|
return (IP_FILE *)stdout;
|
|
#endif
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_stderr
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_PUBLIC IP_FILE *
|
|
ipcom_stderr(void)
|
|
{
|
|
#ifdef IP_PORT_VXWORKS
|
|
return (IP_FILE *)stderr;
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
|
return ipcom_shell_stdio(2);
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
|
return IP_FILE_STDERR;
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
|
return (IP_FILE *)IP_NULL;
|
|
#else
|
|
return (IP_FILE *)stderr;
|
|
#endif
|
|
}
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipcom_stdin
|
|
*===========================================================================
|
|
* Description:
|
|
* Parameters:
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_PUBLIC IP_FILE *
|
|
ipcom_stdin(void)
|
|
{
|
|
#ifdef IP_PORT_VXWORKS
|
|
return (IP_FILE *)stdin;
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_IPCOM
|
|
return ipcom_shell_stdio(0);
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_MINI
|
|
return IP_FILE_STDIN;
|
|
#elif IPCOM_USE_SHELL == IPCOM_SHELL_NONE
|
|
return (IP_FILE *)IP_NULL;
|
|
#else
|
|
return (IP_FILE *)stdin;
|
|
#endif
|
|
}
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|
|
|