00001 #include "openem.h"
00002
00003 #include "services/console.h"
00004
00005
00006
00007
00008 OE_CONSOLE::OE_CONSOLE()
00009 {
00010 curlen = buflen = 0;
00011 buf = NULL;
00012 }
00013
00014 OE_CONSOLE::~OE_CONSOLE()
00015 {
00016 if (curlen) free(buf);
00017 buf = NULL;
00018 curlen = buflen = 0;
00019 }
00020
00021 void OE_CONSOLE::print(char *str)
00022 {
00023 uint32 len = strlen(str);
00024 if (len == 0) return;
00025 curlen += len;
00026 if (curlen == len) {
00027 buf = (char *)malloc(len+1);
00028 sprintf(buf,"%s",str);
00029 }
00030 else {
00031 char *newbuf = (char *)malloc(curlen+len+1);
00032 sprintf(newbuf,"%s",buf);
00033 sprintf(newbuf+strlen(buf),"%s",str);
00034 free(buf);
00035 buf = newbuf;
00036 }
00037 }
00038
00039 void OE_CONSOLE::empty(void)
00040 {
00041 if (curlen) free(buf);
00042 buf = NULL;
00043 curlen = buflen = 0;
00044 }
00045
00046 char *OE_CONSOLE::get_buf()
00047 {
00048 return buf;
00049 }
00050
00051 uint32 OE_CONSOLE::get_len(void)
00052 {
00053 return curlen;
00054 }