Esempio n. 1
0
bool Session::rpcSendMessage(void *data, qint32 len) {
    qCDebug(TG_CORE_SESSION) << "rpcSendMessage()," << len;

    qint32 written;
    Q_UNUSED(written);

    mAsserter.check(len > 0 && !(len & 0xfc000003));
    qint32 totalLen = len >> 2;

    if (totalLen < 0x7f) {
        written = writeOut(&totalLen, 1);
        if(written != 1)
            return false;
    } else {
        totalLen = (totalLen << 8) | 0x7f;
        written = writeOut(&totalLen, 4);
        if(written != 4)
            return false;
    }

    written = writeOut(data, len);
    if(written != len)
        return false;

    return true;
}
Esempio n. 2
0
int main (int argc, char **argv)
{
  int		row, col, iter, keep_going;
  int 		*result = 0;
  double 	re, im;

  keep_going = initRanges (argc, argv);
  if (!keep_going) {
      usage (argc, argv);
      exit (-1);
  }

  result = (int *) malloc (XPIX * YPIX * sizeof (*result));

  for (row = 0; row < YPIX; row++) {
      im = IM_START + row * (IM_STOP - IM_START) / (YPIX - 1.0);
      for (col = 0; col < XPIX; col++) {
	  re = RE_START + col * (RE_STOP - RE_START) / (XPIX - 1.0);
	  iter = iterate (re, im, MAXITER);
	  result[row * XPIX + col] = iter;
      }
      //fprintf (stdout, "%8d\r", row); fflush (stdout);
  }

  writeOut (argv[0], 1, result);
  return 0;
}
Esempio n. 3
0
void onStart() {
    readIn();
    initAllGPU("matrixmul.cl", clCallFunc);
    executeGPU(clCallFunc);
    writeOut();
    destroyGPU(clCallFunc);
}
Esempio n. 4
0
int main(int argc, char** argv)
{  
  size_t from_len = arrlen(argv[1]);

  /* Return error if 'from' & 'to' don't have the same size */
  if(from_len != arrlen(argv[2])) 
    goto ERROR_LEN_EXIT;

  /* Return error if 'from' contains duplicates */
  if(containsDuplicates(argv[1],from_len))
    goto ERROR_DUP_EXIT;

  int buffer;
  size_t i;
  while (readIn(buffer) != EOF) 
  {    
    /* If read byte belongs to 'from', then translate it */
    for(i=0;i<from_len;i++)
      if(buffer == argv[1][i])
	buffer = argv[2][i];

    writeOut(buffer);
  } 

  exit(0);

 ERROR_LEN_EXIT:
    fprintf(stdout,"'from' and 'to' are not the same length\n");
    exit(1);
 ERROR_DUP_EXIT:
    fprintf(stdout,"'from' contains duplicates \n");
    exit(1);
}
/**
*     Main Memory Manager
*/
int main(int arc, char** argv)
{
	if (arc == 1)		initialize(inputfile_default);
	else				initialize(argv[1]);

	while (fgets(line , MaxStringLength, addresses))
	{
		// Read new virtual Address
		int virtualAddress = atoi(line);
		int segmentNumber = (virtualAddress / PageBits / OffsetBits) & (SegmentBits - 1);
		int pageNumber =  (virtualAddress / OffsetBits) & (PageBits - 1);
		int offset = virtualAddress & (OffsetBits - 1);

		// Segmentation Number consideration (only 4 segmentations)
		segmentNumber = _statistics->TranslatedAddressesCounter % SegmentsAmount;

		// Find frameNumber
		int frameNumber = findFrameNumber(segmentNumber, pageNumber);
		
		// Parse real Address
		int frameIndex = frameNumber - segmentNumber*FramesAmount;
		int value = _memory->frame[frameNumber].PageContent[offset];
		int realAddress = frameIndex*PagesAmount + offset;
	  	writeOut(segmentNumber, virtualAddress, realAddress, value);

		// Debugging PageAddress and FrameAddress
		//debugPageAddress(virtualAddress, segmentNumber, pageNumber, offset);
		//debugFrameAddress(realAddress, segmentNumber, frameNumber, offset);
	}
	finalize();
	return 0;
}
Esempio n. 6
0
void onStart() {
    initAllGPU("vecdot.cl", clCallFunc);
    while (readIn()) {
        executeGPU(clCallFunc);
        writeOut();
    }
    destroyGPU(clCallFunc);
}
void CameraPoseOptimization::writeTransformation(std::string strTimeStamp, mat4f& mat, std::string strTrajfilename)
{
	std::ofstream writeOut(strTrajfilename, std::ios::app); // write the data appending to the end of the file
	writeOut << strTimeStamp << " ";
	for (unsigned i = 0; i != 4; ++i)
		for (unsigned j = 0; j != 4; ++j)
			writeOut << mat(i, j) << " ";
	writeOut << std::endl;
	writeOut.close();
}
Esempio n. 8
0
void hashTree::writeOut(ofstream & out, treeNode * root)
{
    if(root)
	{
		char name[100];
		char phone[100];
        char product[100];
        char events[100];
		root->item->getName (name);
		root->item->getPhone(phone);
        root->item->getProduct(product);
        root->item->getEvents(events);
        
		out << name << ';' << phone << ';' << product << ';' << events << '\n';
        
		writeOut(out, root->left);
		writeOut(out, root->right);
	}
}
void CameraPoseOptimization::writeTransformationInQuaternion(std::string strTimeStamp, mat4f& mat, std::string strTrajfilename)
{
	Matrix3f m;
	for (int i = 0; i != 3; i++)
		for (int j = 0; j != 3; j++)
			m(i, j) = mat(i, j);
	Quaternionf q(m);
	std::ofstream writeOut(strTrajfilename, std::ios::app); // write the data appending to the end of the file
	writeOut << strTimeStamp << " ";
	writeOut << mat(0, 3) << " " << mat(1, 3) << " " << mat(2, 3) << " " << q.x() << " " << q.y() << " " << q.z() << " " << q.w() << std::endl;
	writeOut.close();
}
Esempio n. 10
0
void hashTree::writeOut(const char * fileName)
{
    ofstream out;
    out.open(fileName);
    if(!out)
    {
        cerr << "Unable to writeout file: \"" << fileName << "\"" << endl;
        exit(2);
    }
    
    writeOut(out, root);
    out.close();
}
void Connection::onConnected() {
    // stop trying reconnect if it was alive
    stopReconnecting();

    // abridged version of the protocol requires sending 0xef byte at beginning
    unsigned char byte = 0xef;
    qint32 writtenBytes = writeOut(&byte, 1);
    Q_UNUSED(writtenBytes);
    Q_ASSERT(writtenBytes == 1);

    // process the rest of operations in inherited classes
    processConnected();
}
Esempio n. 12
0
void ioexp::IOExpDio::configureInPD(ioexp::IOExpPin pin)
{
	pdir &= ~(unsigned char)pin;

	std::vector<unsigned char> msg1 = {CMD_SET_PDIR, pdir};
	mbus->write(address, msg1);
	
	pren |= (unsigned char)pin;

	std::vector<unsigned char> msg2 = {CMD_SET_REN, pren};
	mbus->write(address, msg2);

	writeOut(pin, ioexp::IOExpLogVal::LOW);
	
	mbus->read(address, CMD_GET_PIN, 1);
}
Esempio n. 13
0
void Korn::dialogClosed(int ret )
{
	QList<KornBox> *list = _optionsDialog->list();

	if( _noConfig && !ret) {
		ret = KMsgBox::yesNo(0, i18n("korn: no config set"), 
				i18n("Would you like to restart korn with\n"
				"the automatically generated configuration?"),
				KMsgBox::QUESTION,
				i18n("Yes, Restart"), i18n("No, Exit"));

		if( ret == 2 ) {
			delete _optionsDialog;
			_optionsDialog = 0;
			qApp->quit();
			return;
		}
	}

	if ( ret ) {
		// Here we should compare lists to see if any have
		// been deleted. If they have, they should be deleted
		// from the config as well.
		// NOTE: No such KConfig feature exists as yet. 9/Jun/97

		writeOut ( list );	

		list->setAutoDelete( TRUE );
		list->clear();
		delete list;

		execvp( qApp->argv()[0], qApp->argv() );
	}

	list->setAutoDelete( TRUE );
	list->clear();
	delete list;
	delete _optionsDialog;

	_optionsDialog = 0;
}
Esempio n. 14
0
//This method creates process to run writeOut by forking the current process.
void createWriteOut(){
	pid_t childPID;
	switch(childPID = fork()){
		//Checks if process was forked successfully
		case -1:
			perror("fork failed");
			exit(EXIT_FAILURE);
		//If it is a child process, then it closes the appropriate pipes and calls writeOut
		case 0:
			close(pipe1[0]);
			close(pipe1[1]);
			close(pipe2[1]);
			close(pipe2[0]);
			close(pipe3[1]);
			writeOut(pipe3[0]);
			break;
		//The parent now waits for writeOut to finish
		default:
			wait();
	}
}
Esempio n. 15
0
void renameFile(char * filePath, char * outDir, double minEasting, double minNorthing, int blkSize)
{
	printf("renameFile : \n\tPutting : %s\n\tIn : %s\n", filePath, outDir);
	
	char outPath [256], fName [32];
	
	FILE * fp;
	
	int numPts, x, y;
	
	if((fp = fopen(filePath, "r")) == NULL)
		return;
		
	double ** origPoints, ** filteredPoints;
	
	if((origPoints = bufferFile(fp, &numPts)) == NULL)
		return;
	
	if(numPts <= 0)
		return;
	
	filteredPoints =
	byeByeBirdie(origPoints, numPts, &numPts); //ensure this is legit
	
	freeDoubleBuffer2D(origPoints, 3);
	
	if(numPts <= 0) 
		return;
	
	getXandY(filteredPoints[0][0], filteredPoints[1][0], minEasting, minNorthing, blkSize, &x, &y);
	
	sprintf(fName, "CHM_%d_%d.txt", x, y);
	strcpy(outPath, outDir);
	strcat(outPath, "/");
	strcat(outPath, fName);
	
	writeOut(outPath, filteredPoints, numPts);
	
	freeDoubleBuffer2D(filteredPoints, 3);
}
Esempio n. 16
0
LogStream::~LogStream()
{
	writeOut();
}
Esempio n. 17
0
int main (int argc, char **argv)
{
  int 		row, col, iter, keep_going, nprocs, myrank;
  int 		*result = 0;
  double 	re, im;
  MPI_Request 	*recv_reqs = 0;

  MPI_Init (&argc, &argv);
  MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
  MPI_Comm_rank (MPI_COMM_WORLD, &myrank);

  if (nprocs < PROCLIMIT) {
      MPI_Finalize ();
      exit (-1);
  }

  if (0 == myrank) keep_going = initRanges (argc, argv);
  MPI_Bcast (&keep_going, 1, MPI_INT, 0, MPI_COMM_WORLD);
  if (!keep_going) {
      if (0 == myrank)usage (argc, argv);
      MPI_Finalize ();
      exit (-1);
  }

  distributeRanges ();

  /* for simplicity we allow the full matrix in each rank: */
  result = (int *) malloc (XPIX * YPIX * sizeof (*result));

  /* set up the MPI_Irecvs needed. We use the tag of the
     MPI messages to let each result fall into place:
   */
  if (0 == myrank) {
      recv_reqs = (MPI_Request *) malloc (YPIX * sizeof (MPI_Request));
      for (row = 0; row < YPIX; row++)
	  MPI_Irecv(result + (row * XPIX), XPIX, MPI_INT,
		    MPI_ANY_SOURCE /* we do not care who does the job */ ,
		    row /* tag */ ,
		    MPI_COMM_WORLD, recv_reqs + row);
  }

#ifdef IDLEROOT
  if (myrank != 0)
#endif
    for (row = 0; row < YPIX; row++)
      if (MYROW (nprocs, myrank, row)) {
	  im = IM_START + row * (IM_STOP - IM_START) / (YPIX - 1.0);
	  for (col = 0; col < XPIX; col++) {
	      re = RE_START + col * (RE_STOP - RE_START) / (XPIX - 1.0);
	      iter = iterate (re, im, MAXITER);
	      result[row * XPIX + col] = iter;
	  }
	  /* report row back to root: */
	  MPI_Send(result + row * XPIX, XPIX, MPI_INT,
		   0, row, MPI_COMM_WORLD);
      }

  /* complete all Irecvs: */
  if (0 == myrank) MPI_Waitall (YPIX, recv_reqs, MPI_STATUSES_IGNORE);

  MPI_Finalize ();

  if (0 == myrank) writeOut (argv[0], nprocs, result);
  return 0;
}
Esempio n. 18
0
			void flushUnified()
			{
				unify();
				writeOut();
			}
Esempio n. 19
0
			void flush()
			{
				writeOut();
			}
int main(int argc, char *argv[])
{
struct lineFile *stf,*zmf, *gzf, *uaf, *zaf;
FILE *sto; 
char filename[256];
int verb = 0;

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc < 7)
    {
fprintf(stdout, "USAGE: formatZfishSts [-verbose=<level>] <UniSTS file> <genbank.txt> <UniSTS aliases> <ZFIN aliases> <ZFIN mappings.txt> <dbSTS map panels>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

stf = lineFileOpen(argv[1], TRUE);
zmf = lineFileOpen(argv[2], TRUE);
gzf = lineFileOpen(argv[3], TRUE);
uaf = lineFileOpen(argv[4], TRUE);
zaf = lineFileOpen(argv[5], TRUE);

stderr = mustOpen("/cluster/bluearc/danRer1/stsMarkers/formatOut/error.log", "w");
sprintf(filename, "%s.format", argv[6]);
sto = mustOpen(filename, "w");

/* Read in STS markers file */
verbose(1, "Reading STS markers file\n");
readStsMarkers(stf);

/* Read in ZFIN Ids, maps and marker names from mapping.txt */
verbose(1, "Reading mapping.txt file\n");
readZfinMapping(zmf);

/* Read in genbank accessions that have ZFIN IDs */
verbose(1, "Reading genbank accession and ZFIN ID file\n");
readGbZfin(gzf);

/* Read in UniSTS alias information */
verbose(1, "Reading UniSTS aliases file\n");
readUnistsAliases(uaf);
/* Read in ZFIN marker IDs with old names */
verbose(1, "Reading ZFIN marker IDs and old names - aliases from a file\n");
readZfinAliases(zaf);

/* Print out the STS marker information to a file */
verbose(1, "Creating output file\n");
writeOut(sto);

lineFileClose(&stf);
lineFileClose(&zmf);
lineFileClose(&gzf);
lineFileClose(&uaf);
lineFileClose(&zaf);
fclose(sto);
fclose(stderr);

freeHash(&stsHash);
freeHash(&stsIdHash);
freeHash(&zfinMarkerHash);
freeHash(&zfinIdHash);
freeHash(&aliasByNameHash);
freeHash(&aliasHash);
return(0);
}
Esempio n. 21
0
int main(int argc, char *argv[])
{
  struct lineFile *sif, *dsf, *daf, *gbf;
  FILE *of, *opf, *oaf, *off, *asf, *dff;
  char filename[256], *gbName;
  int verb = 0;

verboseSetLevel(0);
optionInit(&argc, argv, optionSpecs);
if (argc < 3)
    {
      fprintf(stderr, "USAGE: updateStsInfo [-verbose=<level> -gb=<file>] <stsInfo file> <all.STS.fa> <dbSTS.sts> <dbSTS.aliases> <dbSTS.convert.fa> <outfile prefix>\n");
    return 1;
    }
verb = optionInt("verbose", 0);
verboseSetLevel(verb);

 gbName = optionVal("gb", NULL);
 if (gbName) 
   gbf = lineFileOpen(gbName, TRUE);
 sif = lineFileOpen(argv[1], TRUE);
 asf = mustOpen(argv[2], "r");
 dsf = lineFileOpen(argv[3], TRUE);
 daf = lineFileOpen(argv[4], TRUE);
 dff = mustOpen(argv[5], "r");

 safef(filename, ArraySize(filename), "%s.info", argv[6]);
 of = mustOpen(filename, "w");
 safef(filename, ArraySize(filename), "%s.primers", argv[6]);
 opf = mustOpen(filename, "w");
 safef(filename, ArraySize(filename), "%s.alias", argv[6]);
 oaf = mustOpen(filename, "w");
 safef(filename, ArraySize(filename), "%s.fa", argv[6]);
 off = mustOpen(filename, "w");

 /* Read in current stsInfo file */
 verbose(1, "Reading current stsInfo file: %s\n", argv[1]);
 readStsInfo(sif);

 /* Read in genbank accessions that have sequences */ 
 if (gbName)
   {
     verbose(1, "Reading genbank accession file: %s\n", gbName);
     readGbAcc(gbf);
   }

 /* Read in primer and organism information from dbSTS.sts */
 verbose(1, "Reading current dbSTS.sts file: %s\n", argv[3]);
 readDbstsPrimers(dsf);

 /* Read in names from dbSTS.alias and create new stsInfo records if needed */
 verbose(1, "Reading current dbSTS.aliases file: %s\n", argv[4]);
 readDbstsNames(daf);

 /* Read in current sequences for sts markers */
 verbose(1, "Reading current all.STS file: %s\n", argv[2]);
 readAllSts(asf);

 /* Read in new sequences from dbSTS.fa */
 verbose(1, "Reading dbSTS.fa file: %s\n", argv[5]);
 readDbstsFa(dff);

 /* Print out the new files */
 verbose(1, "Creating output files: %s .info .primers .alias .fa\n", argv[6]);
 writeOut(of, opf, oaf, off);

 fclose(asf);
 lineFileClose(&dsf);
 lineFileClose(&daf);
 fclose(dff);
 if (gbName)
   lineFileClose(&gbf);   
 fclose(of);
 fclose(opf);
 fclose(oaf);
 fclose(off);

 return(0);
}
Esempio n. 22
0
void NGLScene::timerEvent(QTimerEvent *_event)
{
  Data *data = Data::instance();
  ngl::ShaderLib *shader=ngl::ShaderLib::instance();
  if(_event->timerId() == m_timer1){
    QPoint p = mapFromGlobal(QCursor::pos());
    m_mousePos[0] = (p.x() / float(m_width)  * 2) - 1;
    m_mousePos[1] = (p.y() / float(m_height) * 2) - 1;
    m_mousePos[1] *= -1;

    float currentTime = QTime::currentTime().msecsSinceStartOfDay() / 1000.0;

    switch(Data::instance()->mode){
      case Data::DWELLING :
        m_currentButton = checkButtonMouseOver();
        for(Button &button : m_buttons){
          if(m_currentButton && &button == m_currentButton){
            if(button.m_selectedTime == 0){
              button.m_isSelected = true;
              button.m_firstSelected = currentTime;
              button.m_selectedTime = 0.001;
              button.m_color.set(data->selectedColor);
            }
            else{
              button.m_selectedTime = currentTime - button.m_firstSelected;
              if(button.m_selectedTime > data->dwellTime){
                m_action = button.click(currentTime);
              }
            }
          }
          else{
            button.m_color.set(data->baseColor);
            button.m_isSelected = false;
            button.m_firstSelected = 0;
            button.m_selectedTime = 0;
          }
        }
      break;
      case Data::SCANNING :
        if(m_buttons.size() == 1){
          m_currentButton = &(m_buttons[0]);
        }
        if(m_currentButton){
          m_currentButton->m_selectedTime = currentTime - m_currentButton->m_firstSelected;

          if(m_currentButton->m_selectedTime > data->dwellTime){
            m_currentButton->m_isSelected = false;
            m_currentButton->m_selectedTime = 0;

            m_currentButton->m_color.set(data->baseColor);

            if(m_currentButton == &m_buttons[m_buttons.size()-1]){
              m_currentButton = &m_buttons[0];
            }
            else{
              m_currentButton++;
            }

            m_currentButton->m_isSelected = true;
            m_currentButton->m_firstSelected = currentTime;
            m_currentButton->m_color.set(data->selectedColor);
          }
        }

      break;

      case Data::TOUCHLARGE :
      case Data::TOUCHSMALL_L :
      case Data::TOUCHSMALL_R :
      break;

      default :
        std::cerr << "mode not set" << std::endl;
      break;
    }

    int start = 0;
    int dir = 0;
    int rotIndex = 0;
    int hueChange = 0;
    switch(m_action){
      case Button::Action::NONE :
      break;
      case Button::Action::SPIN_CCW :
        if(m_geo[0]->m_localRotation[1] < (m_geo[0]->m_maxAngle)){
          rotIndex = 1;
          start = 0;
          dir += 1;
        }
      break;
      case Button::Action::SPIN_CW :
        if(m_geo[0]->m_localRotation[1] > -(m_geo[0]->m_maxAngle)){
          rotIndex = 1;
          start = 0;
          dir -= 1;
        }
      break;
      case Button::Action::ROTATE_1_R :
          rotIndex = 0;
          if(m_geo[1]->m_localRotation[0] > -(m_geo[1]->m_maxAngle)){
            start = 1;
            dir -= 1;
          }
      break;
      case Button::Action::ROTATE_1_L :
          rotIndex = 0;
          if(m_geo[1]->m_localRotation[0] < m_geo[1]->m_maxAngle){
            start = 1;
            dir += 1;
          }
      break;
      case Button::Action::ROTATE_2_R :
          rotIndex = 0;
          if(m_geo[2]->m_localRotation[0] > -(m_geo[2]->m_maxAngle)){
            start = 2;
            dir -= 1;
          }
      break;
      case Button::Action::ROTATE_2_L :
          rotIndex = 0;
          if(m_geo[2]->m_localRotation[0] < m_geo[2]->m_maxAngle){
            start = 2;
            dir += 1;
          }
      break;
      case Button::Action::ROTATE_3_R :
          rotIndex = 0;
          if(m_geo[3]->m_localRotation[0] > -(m_geo[3]->m_maxAngle)){
            start = 3;
            dir -= 1;
          }
      break;
      case Button::Action::ROTATE_3_L :
          rotIndex = 0;
          if(m_geo[3]->m_localRotation[0] < m_geo[3]->m_maxAngle){
            start = 3;
            dir += 1;
          }
      break;
      case Button::Action::KEY :
        writeKey();
      break;
      case Button::Action::FINISH :
        exit(writeOut());
      break;
      case Button::Action::COLOR_L :
        hueChange = 1;
      break;
      case Button::Action::COLOR_R :
        hueChange = -1;
      break;
      case Button::Action::COLOR_SET :
        m_timer3 = startTimer(data->dwellTime/5 * 1000);
      break;
      default :
        std::cout << "ERROR: button action" << std::endl;
      break;
    }

    if(hueChange){
      data->updateColor(hueChange);
      shader->use("buttonShader");
      shader->setRegisteredUniform("geoColor", data->geoColor);
    }

    m_geo[start]->m_localRotation[rotIndex] += data->rotateAngle * dir;
    for(unsigned int i = start; i<m_geo.size(); i++){
        m_geo[i]->m_rotation[rotIndex] += data->rotateAngle * dir;
    }

    m_action = Button::Action::NONE;

    shader->use("buttonShader");
    shader->setRegisteredUniform("currentTime", currentTime);
    update();
  }
  else if(_event->timerId() == m_timer2){
   m_frame++;
  }
  else if(_event->timerId() == m_timer3){
    m_colorSet = true;
    loadButtons();
    killTimer(m_timer3);
  }
}
Esempio n. 23
0
int main(int argc, char **argv)
{
	bool printUsageAndExit = true;
	bool showDebug = false;
	bool showInfo = false;

	EPath prog(argv[0]);
	EStringArray files;
	const char *lang = "C";
	const char *style = "DocBook";
	const char *options = NULL;
	files.AddItem(NULL);

	const char *tmp_env = getenv("LC_ALL");
	if(tmp_env == NULL) tmp_env = getenv("LANG");
	if(tmp_env != NULL) lang = tmp_env;

	do {
		if(argc < 2) break;

		for(int n = 1; n < argc; n++)
		{
			if(strcmp(argv[n], "-s") == 0)
			{
				if(argc - n < 2) break;
				n++;
				style = argv[n];
			}
			else if(strcmp(argv[n], "-t") == 0)
			{
				if(argc - n < 2) break;
				n++;
				options = argv[n];
			}
			else if(strcmp(argv[n], "-o") == 0)
			{
				if(argc - n < 2) break;
				n++;
				if(files.ReplaceItem(0, argv[n]) == false) break;
			}
			else if(strcmp(argv[n], "-l") == 0)
			{
				if(argc - n < 2) break;
				n++;
				lang = argv[n];
			}
			else if(strcmp(argv[n], "--debug") == 0)
			{
				showDebug = true;
			}
			else if(strcmp(argv[n], "--showinfo") == 0)
			{
				showInfo = true;
			}
			else
			{
				files.AddItem(argv[n]);
			}
		}

		if(files.CountItems() < 2) break;

		printUsageAndExit = false;
	} while(false);

	if(printUsageAndExit)
	{
		print_usage(prog.Leaf());
		exit(1);
	}

	EString xml_buffer;
	EString strDocStart = "<document ";
	EString strDocEnd = "</document>";

	for(eint32 i = 1; i < files.CountItems(); i++)
	{
		if(files.ItemAt(i) == NULL) continue;
		EPath readInPath(files.ItemAt(i)->String(), NULL, true);
		EFile readIn(readInPath.Path(), E_READ_ONLY);
		if(readIn.InitCheck() != E_OK)
		{
			ETK_DEBUG("[%s] --- Unable to read \"%s\".", prog.Leaf(), files.ItemAt(i)->String());
			continue;
		}

		eint32 old_length = xml_buffer.Length();

		char buffer[BUFFER_SIZE];
		bool foundDocEnd = true;
		size_t nLeave = 0;
		xml_buffer.AppendFormat("<!-- convert from \"%s\" -->\n", readInPath.Leaf());
		while(true)
		{
			ssize_t len = readIn.Read(buffer + nLeave, BUFFER_SIZE - nLeave);
			if(len <= 0) break;
			EString str;
			str.SetTo(buffer, len + nLeave);
			str.RemoveAll("\r");
			eint32 offset = 0;
			while(offset >= 0 && offset < str.Length())
			{
				nLeave = 0;
				if(foundDocEnd)
				{
					offset = str.FindFirst("/*", offset);
					if(offset < 0)
					{
						if(str.Length() < 2) break;
						if(str[str.Length() - 1] == '/' && str[str.Length() - 2] != '*') nLeave = 1; break;
					}

					nLeave = str.Length() - offset;
					offset = str.FindFirst("\n", offset);
					if(offset < 0)
					{
						if(nLeave > 80) nLeave = 0;
						break;
					}
					nLeave = 0;

					offset++;
					if(offset >= str.Length()) break;

					if(strDocStart.Compare(str.String() + offset, strDocStart.Length()) != 0)
					{
						eint32 tmp = str.FindLast("<");
						if(tmp >= 0 && str.Length() - tmp < strDocStart.Length())
						{
							nLeave = str.Length() - tmp;
						}
						else
						{
							nLeave = 0;
						}
						continue;
					}

					foundDocEnd = false;
				}

				eint32 endOffset = str.FindFirst(strDocEnd, offset);
				if(endOffset >= 0)
				{
					endOffset += strDocEnd.Length();
					foundDocEnd = true;
					nLeave = 0;
				}
				else
				{
					eint32 tmp = str.FindLast("<");
					if(tmp >= 0 && str.Length() - tmp < strDocEnd.Length())
					{
						nLeave = str.Length() - tmp;
					}
					else
					{
						nLeave = 0;
					}
				}

				xml_buffer.Append(str.String() + offset, (endOffset >= 0 ? endOffset : str.Length()) - offset - nLeave);
				if(foundDocEnd) xml_buffer.Append("\n");
				offset = endOffset;
			}
			if(nLeave > 0) str.CopyInto(buffer, BUFFER_SIZE, str.Length() - nLeave, nLeave);
		}

		if(foundDocEnd == false)
		{
			xml_buffer.Remove(old_length, -1);
			ETK_DEBUG("[%s] --- Invalid document \"%s\".", prog.Leaf(), readInPath.Path());
		}
	}

	EString output_buffer;

	if(strcmp(style, "None") == 0)
	{
		output_buffer.Adopt(xml_buffer);
	}
	else if(strcmp(style, "DocBook") == 0)
	{
		xml_buffer.ReplaceAll("&", "&amp;");
		xml_buffer.ReplaceAll("&amp;lt;", "&lt;");
		xml_buffer.ReplaceAll("&amp;gt;", "&gt;");
		xml_buffer.ReplaceAll("&amp;nbsp;", "&nbsp;");
		xml_buffer.ReplaceAll("©", "&copy;");
		xml_buffer.ReplaceAll("®", "&reg;");
		xml_buffer.ReplaceAll("\n", "&br;");

		eint32 offset = 0;
		while(offset >= 0 && offset < xml_buffer.Length())
		{
			if((offset = xml_buffer.FindFirst(">", offset)) < 0) break;
			eint32 tmp = xml_buffer.FindFirst("<", offset);
			if(tmp < 0 || tmp - offset <= 1) {offset = tmp; continue;}
			EString str;
			xml_buffer.MoveInto(str, offset + 1, tmp - offset);
			str.ReplaceAll(" ", "&nbsp;");
			xml_buffer.Insert(str, offset + 1);
			offset += str.Length() + 1;
		}

		ESimpleXmlNode node(NULL, NULL);
		if(etk_parse_simple_xml(xml_buffer.String(), &node) != E_OK)
		{
			ETK_OUTPUT("[%s] --- Unable to parse.\n", prog.Leaf());
			exit(1);
		}

		ESimpleXmlNode *aNode = NULL;
		offset = 0;
		while(offset >= 0 && offset < node.CountNodes())
		{
			if((offset = node.FindNode("document", offset)) < 0) break;
			if((aNode = node.NodeAt(offset)) == NULL) break;

			eint32 index = aNode->FindAttribute("lang");
			const char *tmp = NULL;
			if(index < 0 || aNode->AttributeAt(index, &tmp) == NULL || tmp == NULL || strcmp(tmp, lang) != 0)
			{
				aNode->RemoveSelf();
				delete aNode;
				continue;
			}

			offset++;
		}

		aNode = find_xml_node_deep(&node, "documentinfo");
		if(aNode != NULL)
		{
			if(!showInfo)
			{
				ESimpleXmlNode *cNode = aNode->NodeAt(aNode->FindNode("title"));
				if(cNode) cNode->RemoveSelf();
				ESimpleXmlNode *nNode;
				while((nNode = aNode->NodeAt(0)) != NULL) {nNode->RemoveSelf(); delete nNode;}
				if(cNode) aNode->AddNode(cNode);
			}
			aNode->RemoveSelf();
			if(node.AddNode(aNode) == false) delete aNode;
		}

		foreach_xml_node(&node, NULL, docbook_foreach, NULL);

		if(showDebug) node.PrintToStream();

		if(convert_to_docbook(&node, &output_buffer, options, lang) != E_OK)
		{
			ETK_OUTPUT("[%s] --- Unable to convert to \"DocBook\" style.\n", prog.Leaf());
			exit(1);
		}
	}
	else
	{
		ETK_OUTPUT("[%s] --- style \"%s\" unsupport yet.\n", prog.Leaf(), style);
		exit(1);
	}

	if(files.ItemAt(0) == NULL || files.ItemAt(0)->String() == NULL)
	{
		for(eint32 offset = 0; offset < output_buffer.Length(); offset += BUFFER_SIZE)
		{
			EString str(output_buffer.String() + offset, BUFFER_SIZE);
			fprintf(stdout, "%s", str.String());
		}
	}
	else
	{
		EFile writeOut(files.ItemAt(0)->String(), E_WRITE_ONLY | E_CREATE_FILE | E_ERASE_FILE);
		if(writeOut.InitCheck() != E_OK)
		{
			ETK_OUTPUT("[%s] --- Unable to write \"%s\".\n", prog.Leaf(), files.ItemAt(0)->String());
			exit(1);
		}
		else
		{
			for(eint32 offset = 0; offset < output_buffer.Length(); offset += BUFFER_SIZE)
				writeOut.Write(output_buffer.String() + offset, min_c(BUFFER_SIZE, output_buffer.Length() - offset));
		}
	}

	return 0;
}