- refactored
- improved checks git-svn-id: http://moon:8086/svn/mips@190 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+20
-21
@@ -14,8 +14,7 @@ extern const con_if_t con_if;
|
|||||||
con_if_entry_t const* con_getInterface(int file)
|
con_if_entry_t const* con_getInterface(int file)
|
||||||
{
|
{
|
||||||
con_if_entry_t const *result = NULL;
|
con_if_entry_t const *result = NULL;
|
||||||
int i;
|
for (int i=0; i < con_if.length; i++)
|
||||||
for (i=0; i < con_if.length; i++)
|
|
||||||
{
|
{
|
||||||
if (file == con_if.con_if_entry[i].fd)
|
if (file == con_if.con_if_entry[i].fd)
|
||||||
{
|
{
|
||||||
@@ -29,8 +28,7 @@ con_if_entry_t const* con_getInterface(int file)
|
|||||||
con_if_entry_t const* con_getInterfaceByName(char const *pName)
|
con_if_entry_t const* con_getInterfaceByName(char const *pName)
|
||||||
{
|
{
|
||||||
void const *result = NULL;
|
void const *result = NULL;
|
||||||
int i;
|
for (int i=0; i < con_if.length; i++)
|
||||||
for (i=0; i < con_if.length; i++)
|
|
||||||
{
|
{
|
||||||
if (!strcmp(pName, con_if.con_if_entry[i].pName))
|
if (!strcmp(pName, con_if.con_if_entry[i].pName))
|
||||||
{
|
{
|
||||||
@@ -44,8 +42,7 @@ con_if_entry_t const* con_getInterfaceByName(char const *pName)
|
|||||||
void const* con_getInstanceByName(char const *pName)
|
void const* con_getInstanceByName(char const *pName)
|
||||||
{
|
{
|
||||||
void const *result = NULL;
|
void const *result = NULL;
|
||||||
int i;
|
for (int i=0; i < con_if.length; i++)
|
||||||
for (i=0; i < con_if.length; i++)
|
|
||||||
{
|
{
|
||||||
if (!strcmp(pName, con_if.con_if_entry[i].pName))
|
if (!strcmp(pName, con_if.con_if_entry[i].pName))
|
||||||
{
|
{
|
||||||
@@ -58,17 +55,17 @@ void const* con_getInstanceByName(char const *pName)
|
|||||||
|
|
||||||
int con_open(char const *pName)
|
int con_open(char const *pName)
|
||||||
{
|
{
|
||||||
int i;
|
if(pName)
|
||||||
assert(pName);
|
|
||||||
|
|
||||||
for (i=0; i < con_if.length; i++)
|
|
||||||
{
|
{
|
||||||
if (!strcmp(pName, con_if.con_if_entry->pName))
|
for (int i=0; i < con_if.length; i++)
|
||||||
{
|
{
|
||||||
if (con_if.con_if_entry->openFunc)
|
if (!strcmp(pName, con_if.con_if_entry->pName))
|
||||||
{
|
{
|
||||||
con_if.con_if_entry->openFunc(&con_if.con_if_entry[i].pInst);
|
if (con_if.con_if_entry->openFunc)
|
||||||
return i;
|
{
|
||||||
|
con_if.con_if_entry->openFunc(&con_if.con_if_entry[i].pInst);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,17 +82,20 @@ void con_flush(int fd)
|
|||||||
int c;
|
int c;
|
||||||
con_if_entry_t const *pIF = con_getInterface(fd);
|
con_if_entry_t const *pIF = con_getInterface(fd);
|
||||||
|
|
||||||
do
|
if (pIF && pIF->readchar)
|
||||||
{
|
{
|
||||||
c = pIF->readchar(pIF->pInst);
|
do
|
||||||
|
{
|
||||||
} while(c > 0);
|
c = pIF->readchar(pIF->pInst);
|
||||||
|
|
||||||
|
} while(c > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int con_readchar(con_if_entry_t const *pIF)
|
int con_readchar(con_if_entry_t const *pIF)
|
||||||
{
|
{
|
||||||
int c = -1;
|
int c = -1;
|
||||||
if (pIF)
|
if (pIF && pIF->readchar)
|
||||||
{
|
{
|
||||||
// busy read
|
// busy read
|
||||||
do
|
do
|
||||||
@@ -109,7 +109,7 @@ int con_readchar(con_if_entry_t const *pIF)
|
|||||||
|
|
||||||
void con_writechar(con_if_entry_t const *pIF, char c)
|
void con_writechar(con_if_entry_t const *pIF, char c)
|
||||||
{
|
{
|
||||||
if (pIF)
|
if (pIF && pIF->writechar)
|
||||||
{
|
{
|
||||||
pIF->writechar(pIF->pInst, c);
|
pIF->writechar(pIF->pInst, c);
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,6 @@ void _putchar(int fd, char c)
|
|||||||
writechar(fd, 0x0D);
|
writechar(fd, 0x0D);
|
||||||
}
|
}
|
||||||
writechar(fd, c);
|
writechar(fd, c);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char _getchar()
|
char _getchar()
|
||||||
|
|||||||
Reference in New Issue
Block a user