aqhome: add and implement a flush function for fd/tty objects.
This commit is contained in:
@@ -32,8 +32,9 @@
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int _startMsg(AQH_OBJECT *o);
|
||||
static void _endMsg(AQH_OBJECT *o);
|
||||
static int _cbStartMsg(AQH_OBJECT *o);
|
||||
static void _cbEndMsg(AQH_OBJECT *o);
|
||||
static int _cbFlush(AQH_OBJECT *o);
|
||||
static int _getAttn(int fd);
|
||||
static int _setAttn(int fd, int val);
|
||||
static int _fdSetBlocking(int sk, int fl);
|
||||
@@ -51,14 +52,15 @@ AQH_OBJECT *AQH_TtyObject_new(AQH_EVENT_LOOP *eventLoop, int fd, int fdMode)
|
||||
AQH_OBJECT *o;
|
||||
|
||||
o=AQH_FdObject_new(eventLoop, fd, fdMode);
|
||||
AQH_FdObject_SetStartMsgFn(o, _startMsg);
|
||||
AQH_FdObject_SetEndMsgFn(o, _endMsg);
|
||||
AQH_FdObject_SetStartMsgFn(o, _cbStartMsg);
|
||||
AQH_FdObject_SetEndMsgFn(o, _cbEndMsg);
|
||||
AQH_FdObject_SetFlushFn(o, _cbFlush);
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _startMsg(AQH_OBJECT *o)
|
||||
int _cbStartMsg(AQH_OBJECT *o)
|
||||
{
|
||||
if (o) {
|
||||
if (AQH_Object_GetFlags(o) & AQH_TTYOBJECT_FLAGS_NOATTN)
|
||||
@@ -91,7 +93,7 @@ int _startMsg(AQH_OBJECT *o)
|
||||
|
||||
|
||||
|
||||
void _endMsg(AQH_OBJECT *o)
|
||||
void _cbEndMsg(AQH_OBJECT *o)
|
||||
{
|
||||
if (o) {
|
||||
if (!(AQH_Object_GetFlags(o) & AQH_TTYOBJECT_FLAGS_NOATTN)) {
|
||||
@@ -107,6 +109,32 @@ void _endMsg(AQH_OBJECT *o)
|
||||
|
||||
|
||||
|
||||
int _cbFlush(AQH_OBJECT *o)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd=AQH_FdObject_GetFd(o);
|
||||
if (fd>=0) {
|
||||
int rv;
|
||||
|
||||
rv=tcflush(fd, TCIFLUSH);
|
||||
if (rv<0) {
|
||||
if (errno!=EINTR && errno!=EWOULDBLOCK && errno!=EAGAIN) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on tcflush: %s (%d)", strerror(errno), errno);
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Previous error");
|
||||
return GWEN_ERROR_IO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _getAttn(int fd)
|
||||
{
|
||||
int rv;
|
||||
@@ -243,6 +271,7 @@ int _fdSetBlocking(int fd, int fl)
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int _msleep(long int msec)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user