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