printf("Done = %d\n",done); printf("call Done %d\n",sz);
int main(int argc, char** argv) {  char buf[MAXBSIZE];  PRUint32 bs;  if( 3 != argc )  {    usage();    printf("Need 2 arguments\n");    return(-1);  }  bs = atoi(argv[2]);  if((bs <1)||(bs>MAXBSIZE))  {    usage();    printf("blocksize out of range - %s\n", argv[2]);    return(-1);  }  nsresult rev = NS_OK;  nsICharsetDetector *det = nsnull;  rev = GetDetector(argv[1], &det);  if(NS_FAILED(rev) || (nsnull == det) ){    usage();    printf("Invalid Detector - %s\n", argv[1]);    printf("XPCOM ERROR CODE = %x\n", rev);    return(-1);  }  nsICharsetDetectionObserver *obs = nsnull;  rev = GetObserver(&obs);  if(NS_SUCCEEDED(rev)) {    rev = det->Init(obs);    NS_IF_RELEASE(obs);    if(NS_FAILED(rev))    {      printf("XPCOM ERROR CODE = %x\n", rev);      return(-1);    }  } else {    printf("XPCOM ERROR CODE = %x\n", rev);    return(-1);  }  size_t sz;  PRBool done = PR_FALSE;  nsSimpleStatis  ks(0xb0,0xc8, (float)0.95952, "EUC-KR");  nsSimpleStatis  js(0xa4,0xa5, (float)0.45006, "EUC-JP");  nsStatis* stat[2] = {&ks, &js};  PRUint32 i;  do  {    sz = read(0, buf, bs);     if(sz > 0) {      if(! done) {        rev = det->DoIt( buf, sz, &done);        if(NS_FAILED(rev))        {          printf("XPCOM ERROR CODE = %x\n", rev);          return(-1);        }      }      for(i=0;i<2;i++)        stat[i]->HandleData(buf, sz);    }  // } while((sz > 0) &&  (!done) );  } while(sz > 0);  if(!done)  {    rev = det->Done();    if(NS_FAILED(rev))    {      printf("XPCOM ERROR CODE = %x\n", rev);      return(-1);    }  }  for(i=0;i<2;i++) {    stat[i]->DataEnd();    stat[i]->Report();  }printf( "Done\n");    NS_IF_RELEASE(det);printf( "Done 2\n");  return (0);}