forked from enlightenment/efl
Add start of tty code for open/close/etc tty operations
Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
2f78806319
commit
b2590044e9
|
@ -0,0 +1,90 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "ecore_drm_private.h"
|
||||
|
||||
/**
|
||||
* @defgroup Ecore_Drm_Tty_Group Tty manipulation functions
|
||||
*
|
||||
* Functions that deal with opening, closing, and otherwise using a tty
|
||||
*/
|
||||
|
||||
/**
|
||||
* Open a tty for use
|
||||
*
|
||||
* @param dev The Ecore_Drm_Device that this tty will belong to.
|
||||
* @param name The name of the tty to try and open.
|
||||
* If NULL, /dev/tty0 will be used.
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE on failure
|
||||
*
|
||||
* @ingroup Ecore_Drm_Tty_Group
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name)
|
||||
{
|
||||
char tty[32] = "<stdin>";
|
||||
struct stat st;
|
||||
void *data;
|
||||
int fd = -1;
|
||||
Eina_Bool ret = EINA_FALSE;
|
||||
|
||||
/* check for valid device */
|
||||
if ((!dev) || (!dev->devname)) return EINA_FALSE;
|
||||
|
||||
/* assign default tty fd of -1 */
|
||||
dev->tty.fd = -1;
|
||||
|
||||
if (!name)
|
||||
{
|
||||
char *env;
|
||||
|
||||
if ((env = getenv("ECORE_DRM_TTY")))
|
||||
snprintf(tty, sizeof(tty), "%s", env);
|
||||
else
|
||||
{
|
||||
snprintf(tty, sizeof(tty), "%s", "/dev/tty0");
|
||||
// dev->tty.fd = dup(0);
|
||||
}
|
||||
}
|
||||
else // FIXME: NB: This should Really check for format of name (/dev/xyz)
|
||||
snprintf(tty, sizeof(tty), "%s", name);
|
||||
|
||||
if (dev->tty.fd < 0)
|
||||
{
|
||||
/* try to open the tty */
|
||||
_ecore_drm_message_send(ECORE_DRM_OP_TTY_OPEN, tty, strlen(tty));
|
||||
|
||||
/* get the result of the open operation */
|
||||
ret = _ecore_drm_message_receive(ECORE_DRM_OP_TTY_OPEN, &data, sizeof(int));
|
||||
|
||||
fd = *((int *)data);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
DBG("SUCCESS !!!: %d", fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG("FAILURE !!!: %d", fd);
|
||||
}
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an already opened tty
|
||||
*
|
||||
* @param dev The Ecore_Drm_Device which owns this tty.
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE on failure
|
||||
*
|
||||
* @ingroup Ecore_Drm_Tty_Group
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
ecore_drm_tty_close(Ecore_Drm_Device *dev)
|
||||
{
|
||||
return EINA_TRUE;
|
||||
}
|
Loading…
Reference in New Issue