if(strcmp(argv[i], "-f") == 0)
if(strcmp(argv[i], "-t") == 0)
int main(int argc, const char** argv){   nsresult res= NS_OK;   nsICharsetConverterManager* ccMain=nsnull;   // get ccMain;   nsServiceManager::GetService(kCharsetConverterManagerCID,       kICharsetConverterManagerIID, (nsISupports**) &ccMain);   if(NS_FAILED(res))   {	 fprintf(stderr, "Cannot get Character Converter Manager %x\n", res);   }   int i;   if(argc > 5)   {     for(i =0; i < argc; i++)     {       if(strcmp(argv[i], "-t") == 0)       {             tocodeind = i+1;             nsAutoString str(argv[tocodeind]);             res = ccMain->GetUnicodeDecoder(&str, &decoder);             if(NS_FAILED(res)) {	     	fprintf(stderr, "Cannot get Unicode decoder %s %x\n", 			argv[tocodeind],res);  		return -1;	     }       }       if(strcmp(argv[i], "-f") == 0)       {             fromcodeind = i+1;             nsAutoString str(argv[fromcodeind]);             res = ccMain->GetUnicodeEncoder(&str, &encoder);             if(NS_FAILED(res)) {	     	fprintf(stderr, "Cannot get Unicode encoder %s %x\n", 			argv[fromcodeind],res);  		return -1;	     }       }     }     if(argc == 6)     {        infile = fopen(argv[5], "rb");        if(NULL == infile)         {             usage();           fprintf(stderr,"cannot open file %s\n", argv[5]);           return -1;         }     }     else     {        infile = stdin;     }         PRInt32 insize,medsize,outsize;     while((insize=fread(inbuffer, 1,INBUFSIZE,infile)) > 0)     {        medsize=MEDBUFSIZE;        	res = decoder->Convert(medbuffer, 0, &medsize,inbuffer,0,&insize);        if(NS_FAILED(res)) {            fprintf(stderr, "failed in decoder->Convert %x\n",res);	    return -1;	}        outsize = OUTBUFSIZE;	res = encoder->Convert(medbuffer, &medsize, outbuffer,&outsize);        if(NS_FAILED(res)) {            fprintf(stderr, "failed in encoder->Convert %x\n",res);	    return -1;	}        fwrite(outbuffer, 1, outsize, stdout);     }          fclose(infile);     fclose(stdout);     fprintf(stderr, "Done!\n");     return 0;   }   usage();   return -1;}