PUBLIC Stream * new_stream (char * filename, char * mode) { Stream * strm = NEW (Stream); StreamPrivate * priv = NEW (StreamPrivate); priv->s = new_scanner (NULL); priv->o = new_out (); strm->priv = priv; strm->Open = StrmOpen; strm->Close = StrmClose; strm->Write = StrmWrite; strm->WriteFmt = StrmWriteFmt; strm->WriteBinary = StrmWriteBinary; strm->Read = StrmRead; strm->ReadBinary = StrmReadBinary; strm->ReWind = StrmReWind; strm->GetDescriptor = StrmGetDescriptor; strm->SetDescriptor = StrmSetDescriptor; strm->dtor = StrmDtor; if (filename != NULL && mode != NULL) { if ((stream (strm)->Open (filename, mode)) == 0) { stream (strm)->dtor (); strm = NULL; } } return strm; }
int main (int argc, char ** argv) { int a; Scanner * in = new_scanner (stdin); Out * o = new_out (); a = scanner (in)->getInt ();law // printf ("%d", a); out(o)->Stdout ("%d", a); scanner (in)->dtor (); return 0; }
/*======================================================================* TestB *======================================================================*/ void TestB() { int temp=new_out(10); disp_int(temp); display_string(" "); /* int temp=0x500000,i; int delta=0x500000/1024; for (i=0; i<delta; i++){ u8 ret=read_memory(temp); //disp_int(ret); display_string(" "); temp+=1024; } display_string("scan 5MB memory\n"); */ while(1){ //PROCESSB(); } }