Esempio n. 1
0
int main(void)
{
	element* html = readDocument();
	printDocument(html);
	deleteElement(html);

	return 0;
}
Esempio n. 2
0
int main()
{
 
 std::vector<Formatter*> vec;
 
 vec.push_back(new HtmlFormatter());
 vec.push_back(new HtmlFormatter());
 vec.push_back(new HtmlFormatter());
 
 for (size_t i = 0; i < vec.size(); ++i)
 	printDocument(*vec[i]);
 
 
 for (size_t i = 0; i < vec.size(); ++i)
 	delete vec[i];
 
 return 0;
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
  if (argc < 4){
    printf( "Usage: %s <servicename> <directory>|<definition_file> <REQUEST> [<functionname> <param_1>[...<param_n>]]\n", basename(argv[0]) );
    return 1;
  }
 
  map* outputs=NULL;
  /**
   * Parsing inputs (need a loop over all files in the service path !!)
   */
  maps* m;
  m=(maps*)malloc(MAP_SIZE);
  conf_read("main.cfg",m);
  map* tmpm=getMapFromMaps(m,"main","serverAddress");
  int toto=count(tmpm);
  //printf(" - %i \n",toto);

  if(tmpm!=NULL)
    SERVICE_URL=strdup(tmpm->value);
  else
    SERVICE_URL=DEFAULT_SERVICE_URL;

  service* s[100];
  service* s1;
  int scount=0;

  if(strcmp(argv[3],"GetCapabilities")==0){
    int i=0;
    struct dirent *dp;
    DIR *dirp = opendir(argv[1]);
    int t;
    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
    xmlNodePtr n = printGetCapabilitiesHeader(doc,argv[2],m);
    
    int saved_stdout = dup(fileno(stdout));
    stdout = freopen("/dev/null" , "w" , stdout);
    while ((dp = readdir(dirp)) != NULL)
      if(strstr(dp->d_name,".zcfg")!=0){
	char toto1[1024];
	sprintf(toto1,"%s%s",argv[1],dp->d_name);
	char *toto=toto1;
	s1=(service*)malloc(sizeof(char*)+(MAP_SIZE*2)+(2*ELEMENTS_SIZE));
	//s[scount]=(service*)malloc(sizeof(service*));
	//#ifdef DEBUG
	fprintf(stderr,"#################\n%s\n#################\n",toto1);
	//printf("|(1)");
	//#endif
	t=getServiceFromFile(toto1,&s1);
	
	//printf("|(2)");
	printGetCapabilitiesForProcess(m,n,s1);
	/**
	 * Valgrind told us that there is an issue regarding a 
	 * "conditional jump or move depends on uninitialised value(s)" for
	 * freeIOType
	 */
	//freeService(&s1);
	scount++;
      }
    char buf[20];
    sprintf(buf, "/dev/fd/%d", saved_stdout);
    stdout = freopen(buf , "w" , stdout);

    printDocument(doc);
    fflush(stdout);
    free(m);
    return 0;
  }
  else{
    s1=(service*)malloc(sizeof(char*)+(MAP_SIZE*2)+(2*ELEMENTS_SIZE));
    //s[0]=(service*)malloc(sizeof(service*));
    int t=getServiceFromFile(argv[1],&s1);
    if(strcmp(argv[3],"DescribeProcess")==0){
      printDescribeProcessResponse(s1,argv[2]);
      //dumpMaps(m);
      //free(s1);
      return 0;
    }
    else
      if(strcmp(argv[3],"Execute")!=0){
	fprintf(stderr,"");
	//free(s);
	return 0;
      }
  }
  //dumpService(s);
  s[0]=s1;
  map* inputs=NULL;
  elements* c_inputs=s1->inputs;
  int j;
  for(j=0;j<argc-5;j++){
    //dumpElements(c_inputs);
    if(inputs!=NULL)
      addToMap(inputs,c_inputs->name,argv[j+5]);
    else
      inputs=createMap(c_inputs->name,argv[j+5]);
    if(c_inputs->next!=NULL || j+1>=argc-5)
      c_inputs=c_inputs->next;
    else{
      map* tmps=createMap("text","ERROR you provided more inputs than requested.");
      printExceptionReportResponse(m,tmps);
      //printf("ERROR you provided more inputs than requested.");
      return -1;
    }
#ifdef DEBUG
    printf("ARGV1 %d %s\n",j,inputs->value);
#endif
  }

#ifdef DEBUG
  dumpMap(inputs);
#endif

  const struct tm *tm;
  size_t len;
  time_t now;
  char *sDate;
  
  now = time ( NULL );
  tm = localtime ( &now );

  sDate = new char[TIME_SIZE];

  len = strftime ( sDate, TIME_SIZE, "%d-%B-%YT%I:%M:%SZ", tm );

#ifdef DEBUG
  printf("Trying to load %s\n", argv[2]);
#endif
  void* so = dlopen(argv[2], RTLD_LAZY);
  char *errstr;
  errstr = dlerror();
  if( so != NULL ) {
    typedef int (*execute_t)(map**,map**);
#ifdef DEBUG
    printf("Library loaded %s \n",errstr);
#endif
    execute_t execute=(execute_t)dlsym(so,argv[4]);
#ifdef DEBUG
    errstr = dlerror();
    printf("Function loaded %s\n",errstr);
#endif	

    /**
     * Need to check if we need to fork to load a status enabled 
     */
    char _toto[10];
    sprintf(_toto,"input_%i",argc-5);
    map* toto=getMap(inputs,_toto);
    if(strcmp(argv[argc-1],"bg")!=0){
#ifdef DEBUG
      printf("RUN IN NORMAL MODE \n");
#endif
      int res=execute(&inputs,&outputs);
#ifdef DEBUG
      printf("RUNNED IN NORMAL MODE \n");
      dumpMap(inputs);
      dumpMap(outputs);
#endif
      printProcessResponse(m,getpid(),s[0],argv[2],res,inputs,outputs);
    }
    else{
      pid_t   pid;
      int cpid=getpid();
      pid = fork ();
      if (pid > 0) {
	/**
	 * dady :
	 * set status to SERVICE_ACCEPTED
	 */
	printProcessResponse(m,pid,s[0],argv[2],SERVICE_ACCEPTED,inputs,outputs);
      }else if (pid == 0) {
	/* son */
	if (signal(SIGINT, sigint_handler) == SIG_ERR) {
	  printf("signal");
	  map* tmps=createMap("text","father received sigint.");
	  printExceptionReportResponse(m,tmps);
	  exit(1);
	}
#ifdef DEBUG
	printf("RUN IN BACKGROUND MODE \n");
#endif
	char tmp1[256];
	sprintf(tmp1,"service/temp/%s_%d.xml",argv[2],getpid());
	stdout = freopen(tmp1 , "w+" , stdout);
	/**
	 * set status to SERVICE_STARTED
	 */
	printProcessResponse(m,getpid(),s[0],argv[2],SERVICE_STARTED,inputs,outputs);
	fflush(stdout);
	rewind(stdout);
	int t=execute(&inputs,&outputs);
	/**
	 * set status to status code returned by the service function
	 */
	printProcessResponse(m,getpid(),s[0],argv[2],t,inputs,outputs);
      } else {
	/* error */
      }
    }
#ifdef DEBUG
    errstr = dlerror();
    printf("Function successfully loaded %s, unloading now.\n",errstr);
#endif
    dlclose(so);
  }
  else {
#ifdef DEBUG
    printf("C Library can't be loaded %s \n",errstr);
#endif
    python_support(m,s[0],argc,argv,inputs,outputs);
  }
  return 0;
}
Esempio n. 4
0
MainWindow::MainWindow( QWidget *parent ):
    QMainWindow( parent )
{
    QWidget *w = new QWidget( this );

    d_plot = new Plot( w );

    d_panner = new QwtPolarPanner( d_plot->canvas() );
    d_panner->setEnabled( false );

    d_zoomer = new QwtPolarMagnifier( d_plot->canvas() );
    d_zoomer->setEnabled( false );

    d_settingsEditor = new SettingsEditor( w );

    d_settingsEditor->showSettings( d_plot->settings() );
    connect( d_settingsEditor, SIGNAL( edited( const PlotSettings & ) ),
        d_plot, SLOT( applySettings( const PlotSettings & ) ) );

    QHBoxLayout *layout = new QHBoxLayout( w );
    layout->addWidget( d_settingsEditor, 0 );
    layout->addWidget( d_plot, 10 );

    setCentralWidget( w );

    QToolBar *toolBar = new QToolBar( this );

    QToolButton *btnZoom = new QToolButton( toolBar );

    const QString zoomHelp =
        "Use the wheel to zoom in/out.\n"
        "When the plot is zoomed in,\n"
        "use the left mouse button to move it.";

    btnZoom->setText( "Zoom" );
    btnZoom->setIcon( QPixmap( zoom_xpm ) );
    btnZoom->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    btnZoom->setToolTip( zoomHelp );
    btnZoom->setCheckable( true );
    toolBar->addWidget( btnZoom );
    connect( btnZoom, SIGNAL( toggled( bool ) ), SLOT( enableZoomMode( bool ) ) );

    QToolButton *btnPrint = new QToolButton( toolBar );
    btnPrint->setText( "Print" );
    btnPrint->setIcon( QPixmap( print_xpm ) );
    btnPrint->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    toolBar->addWidget( btnPrint );
    connect( btnPrint, SIGNAL( clicked() ), SLOT( printDocument() ) );

#ifdef QT_SVG_LIB
    QToolButton *btnExport = new QToolButton( toolBar );
    btnExport->setText( "Export" );
    btnExport->setIcon( QPixmap( print_xpm ) );
    btnExport->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    toolBar->addWidget( btnExport );

    connect( btnExport, SIGNAL( clicked() ), SLOT( exportDocument() ) );
#endif

    addToolBar( toolBar );
}
Esempio n. 5
0
/***************************************************************************
Desc:	Program entry point (main)
****************************************************************************/
extern "C" int main(
	int,			// iArgC,
	char **		// ppucArgV
	)
{
	RCODE						rc = NE_XFLM_OK;
	FLMBYTE					ucMsgBuf[ 200];
	XFLM_CREATE_OPTS		createOpts;
	IF_DbSystem *			pDbSystem = NULL;
	IF_Db *					pDb = NULL;
	IF_Backup *				pBackup = NULL;
	IF_DOMNode *			pTmpNode = NULL;
	FLMUINT					uiMusicElementDef=0;
	FLMUINT					uiCdElementDef=0;
	FLMUINT					uiTitleElementDef=0;
	FLMUINT					uiArtistElementDef=0;
	FLMUINT					uiTracksElementDef=0;
	FLMUINT					uiNoAttrDef=0;
	FLMUINT					uiTitleAttrDef=0;
	FLMUINT					uiCollectionDef=0;
	FLMBOOL					bTranStarted = FALSE;
	IF_DOMNode *			pCdChild = NULL;
	IF_DOMNode *			pCdElement = NULL;
	IF_DOMNode *			pMusicElement = NULL;
	IF_DOMNode *			pCdAttr = NULL;
	IF_DOMNode *			pTrackNode = NULL;
	IF_Query *				pQuery = NULL;
	IF_PosIStream	*		pPosIStream = NULL;
	IF_PosIStream *		pIStream = NULL;
	FLMUINT					uiIndex = 1;
	FLMBYTE					ucUntilKeyBuf[ XFLM_MAX_KEY_SIZE];
	FLMUINT					uiUntilKeyLen;
	FLMBYTE					ucCurrentKeyBuf[ XFLM_MAX_KEY_SIZE];
	FLMUINT					uiCurrentKeyLen;
	FLMUINT64				ui64DocId;
	char						ucTitle[ 200];
	FLMUINT					uiTitleLen;
	char *					ppszPath[] = 
				{
					"7001e10c.xml",
					"70028663.xml",
					"70037c08.xml",
					"70040b08.xml",
					"70044808.xml",
					"70045109.xml",
					"70045e09.xml",
					"70046709.xml",
					"7004920a.xml",
					""
				};
	FLMUINT					uiLoop;
	IF_DataVector *		pFromKeyV = NULL;
	IF_DataVector *		pUntilKeyV = NULL;
	const char *			pszQueryString = "/music/cd/tracks[@title~=\"we our in luv\"]";
	const char *			pszIndex =
		"<xflaim:Index "
			"xmlns:xflaim=\"http://www.novell.com/XMLDatabase/Schema\" "
			"xflaim:name=\"title_IX\">"
			"<xflaim:ElementComponent "
				"xflaim:name=\"title\" "
				"xflaim:IndexOn=\"value\" "
				"xflaim:KeyComponent=\"1\"/>"
		"</xflaim:Index>";

	// Allocate a DbSystem object

	if( RC_BAD( rc = FlmAllocDbSystem( &pDbSystem)))
	{
		goto Exit;
	}

	// Create the database.  This code will remove the database first if it
	// exists.  Once removed, it will try to create it.  If that fails for
	// any reason other than the database already exists, it will exit.

RetryCreate:

	f_memset( &createOpts, 0, sizeof( XFLM_CREATE_OPTS));
	
	if( RC_BAD( rc = pDbSystem->dbCreate( DB_NAME_STR, NULL, NULL, NULL,
			NULL, &createOpts, &pDb)))
	{
		if( RC_BAD( rc == NE_XFLM_FILE_EXISTS))
		{
			if( RC_BAD( rc = pDbSystem->dbRemove( DB_NAME_STR, NULL, NULL, TRUE)))
			{
				goto Exit;
			}

			goto RetryCreate;
		}
		else
		{
			goto Exit;
		}
	}

	// Start an update transaction.  All access to the database should
	// be done within the confines of a transaction.  When changes are being
	// made to the database, an UPDATE transaction is required.  It is best to
	// keep transactions small if possible.

	if( RC_BAD( rc = pDb->transBegin( XFLM_UPDATE_TRANS, FLM_NO_TIMEOUT)))
	{
		goto Exit;
	}
	bTranStarted = TRUE;

	// Let's create a document to demonstrate how we use the DOM...
	// Our document will catalog a music CD.  It will look like:

	// <music>
	// 	<cd>
	// 		<title>We Are In Love</title>
	// 		<artist>Harry Connick Jr.</artist>
	// 		<tracks no="1" title="We Are In Love"/>
	// 		<tracks no="2" title="Only 'Cause I Don't Have You"/>
	// 	</cd>
	// </music>

	// To accomplish this, we must define the elements of the document and a new
	// collection to store the document in.

	// Create some element definitions for our document.
	// Create the "music" element definition.

	if( RC_BAD( rc = pDb->createElementDef( NULL, "music", 
		XFLM_NODATA_TYPE, &uiMusicElementDef)))
	{
		goto Exit;
	}

	// Create the "cd" element definition.

	if( RC_BAD( rc = pDb->createElementDef( NULL, "cd",
		XFLM_NODATA_TYPE, &uiCdElementDef)))
	{
		goto Exit;
	}

	// Create the "title" element definition.

	if( RC_BAD( rc = pDb->createElementDef( NULL, "title",
		XFLM_TEXT_TYPE, &uiTitleElementDef)))
	{
		goto Exit;
	}

	// Create the "artist" element definition.

	if( RC_BAD( rc = pDb->createElementDef( NULL, "artist",
		XFLM_TEXT_TYPE, &uiArtistElementDef)))
	{
		goto Exit;
	}

	// Create the "tracks" element definition.

	if( RC_BAD( rc = pDb->createElementDef( NULL, "tracks",
		XFLM_NODATA_TYPE, &uiTracksElementDef)))
	{
		goto Exit;
	}

	// Create the "no" attribute definition.

	if( RC_BAD( rc = pDb->createAttributeDef( NULL, "no",
		XFLM_NUMBER_TYPE, &uiNoAttrDef)))
	{
		goto Exit;
	}

	// Create the "title" attribute definition.

	if( RC_BAD( rc = pDb->createAttributeDef( NULL, "title",
		XFLM_TEXT_TYPE, &uiTitleAttrDef)))
	{
		goto Exit;
	}

	// Create our special music collection for storing music stuff.

	if( RC_BAD( rc = pDb->createCollectionDef( "Music Collection",
		&uiCollectionDef)))
	{
		goto Exit;
	}

	// We now have all of the definitions we need to build our document.
	// Lets first create a new document, followed by its members...

	// Create the "music" root element

	if( RC_BAD( rc = pDb->createRootElement( uiCollectionDef, uiMusicElementDef,
		&pMusicElement)))
	{
		goto Exit;
	}

	// Create the "cd" element

	if( RC_BAD( rc = pMusicElement->createNode( pDb, ELEMENT_NODE,
		uiCdElementDef, XFLM_FIRST_CHILD, &pCdElement)))
	{
		goto Exit;
	}
	
	// Create the "title" element

	if( RC_BAD( rc = pCdElement->createNode( pDb, ELEMENT_NODE,
		uiTitleElementDef, XFLM_FIRST_CHILD, &pCdChild)))
	{
		goto Exit;
	}

	// Set the value for the title.

	if (RC_BAD( rc = pCdChild->setUTF8( pDb, (FLMBYTE *)"We Are In Love")))
	{
		goto Exit;
	}
	
	// Create the "artist" element

	if( RC_BAD( rc = pCdElement->createNode( pDb, ELEMENT_NODE,
		uiArtistElementDef, XFLM_LAST_CHILD, &pCdChild)))
	{
		goto Exit;
	}

	// Set the value for the title.

	if (RC_BAD( rc = pCdChild->setUTF8( pDb, (FLMBYTE *)"Harry Connick Jr.")))
	{
		goto Exit;
	}
	
	// Create the first "tracks" element

	if( RC_BAD( rc = pCdElement->createNode( pDb, ELEMENT_NODE,
		uiTracksElementDef, XFLM_LAST_CHILD, &pCdChild)))
	{
		goto Exit;
	}

	// Create the "no." attribute, then the "title" attribute.
	
	if (RC_BAD( rc = pCdChild->createAttribute( pDb, uiNoAttrDef, &pCdAttr)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pCdAttr->setUINT( pDb, (FLMUINT)1)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pCdChild->createAttribute( pDb, uiTitleAttrDef, &pCdAttr)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pCdAttr->setUTF8( pDb, (FLMBYTE *)"We Are In Love")))
	{
		goto Exit;
	}

	// Create the next "tracks" element

	if( RC_BAD( rc = pCdElement->createNode( pDb, ELEMENT_NODE,
		uiTracksElementDef, XFLM_LAST_CHILD, &pCdChild)))
	{
		goto Exit;
	}

	// An alternate way to create the attributes and set their values is to use
	// the parent element to set the attribute values.

	// Create the two attributes.

	if (RC_BAD( rc = pCdChild->createAttribute( pDb, uiNoAttrDef, &pCdAttr)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pCdChild->createAttribute( pDb, uiTitleAttrDef, &pCdAttr)))
	{
		goto Exit;
	}

	// Using the parent of the attributes, set their values by specifying
	// which attribute to set.

	if (RC_BAD( rc = pCdChild->setAttributeValueUINT( pDb, uiNoAttrDef,
		(FLMUINT)2)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pCdChild->setAttributeValueUTF8(
		pDb, uiTitleAttrDef, (FLMBYTE *)"Only 'Cause I Don't Have You")))
	{
		goto Exit;
	}

	// It is always good practice to call documentDone whenever updates to a
	// document are completed.

	if (RC_BAD( rc = pDb->documentDone( pMusicElement)))
	{
		goto Exit;
	}

	// Commit the transaction

	if( RC_BAD( rc = pDb->transCommit()))
	{
		goto Exit;
	}
	bTranStarted= FALSE;

	// Now we want to read back our document, and display it for all 
	// the world to see...:^)

	// Start a read transaction

	if( RC_BAD( rc = pDb->transBegin( XFLM_READ_TRANS, 0)))
	{
		goto Exit;
	}
	bTranStarted = TRUE;

	// Read the nodes.  Start with the document node.

	if( RC_BAD( rc = pDb->getFirstDocument( uiCollectionDef, &pTmpNode)))
	{
		goto Exit;
	}

	// printDocument is a simple function that walks through the document
	// and displays it, node by node as an XML document.  It assumes the 
	// node passed in is the root node.  If it is not, then the display will
	// look a bit odd, as you will see later in this sample program.

	if (RC_BAD( rc = printDocument( pDb, pTmpNode)))
	{
		goto Exit;
	}

	// Commit the transaction

	if( RC_BAD( rc = pDb->transCommit()))
	{
		goto Exit;
	}
	bTranStarted = FALSE;

	// Start an update transaction

	if( RC_BAD( rc = pDb->transBegin( XFLM_READ_TRANS, 0)))
	{
		goto Exit;
	}
	bTranStarted = TRUE;

	// Let's do a query on this document...  Our query (above) is
	// deliberately miss-spelling some of the words.  It is looking for
	// the music "tracks" with the title "We Are In Love".
	// The syntax ~= means approximately equals, and is a "sounds like" 
	// search.

	if (RC_BAD( rc = pDbSystem->createIFQuery( &pQuery)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pQuery->setCollection( uiCollectionDef)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pQuery->setupQueryExpr( pDb, pszQueryString)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pQuery->getFirst( pDb, &pTrackNode)))
	{
		goto Exit;
	}

	printMessage( "Query:");
	printMessage( pszQueryString);

	// This will pring the tracks node, followed by all of the closing parent
	// nodes.

	if (RC_BAD( rc = printDocument( pDb, pTrackNode)))
	{
		goto Exit;
	}

	pQuery->Release();
	pQuery = NULL;

	// Commit the transaction

	if( RC_BAD( rc = pDb->transCommit()))
	{
		goto Exit;
	}
	bTranStarted = FALSE;

	// Let's create an index to make searching easier.  An index is essentially
	// just another XML document to XFlaim, however it is created in the dictionary
	// collection rather than in a data collection.  There are two ways to create
	// a document in XFlaim.  One way (demonstrated above) is to create each node
	// of the document, one at a time.  The other is to import the document.
	// Creating the index will demonstrate importing the document.  Our
	// index definition is shown as follows:

	// <xflaim:Index
	// 	xmlns:xflaim="http://www.novell.com/XMLDatabase/Schema"
	// 	xflaim:name="title_IX">
	// 	<xflaim:ElementComponent
	// 		xflaim:name="title"
	// 		xflaim:DictNum="1"
	// 		xflaim:IndexOn="value"/>
	// </xflaim:Index>"

	// For our purposes, we will create a local variable (pszIndex) which
	// holds the index document.  We will import that using the importDocument
	// method of the pDb object.

	// Import the index...
	// We first need to create a BufferIStream object to stream the document
	// from...
	// Start an update transaction

	if( RC_BAD( rc = pDb->transBegin( XFLM_UPDATE_TRANS, FLM_NO_TIMEOUT)))
	{
		goto Exit;
	}
	bTranStarted = TRUE;

	if ( RC_BAD( rc = pDbSystem->openBufferIStream( pszIndex, 
		f_strlen( pszIndex), &pPosIStream)))
	{
		goto Exit;
	}

	if ( RC_BAD( rc = pDb->import( pPosIStream, XFLM_DICT_COLLECTION)))
	{
		goto Exit;
	}

	// Commit the transaction

	if( RC_BAD( rc = pDb->transCommit()))
	{
		goto Exit;
	}
	bTranStarted = FALSE;

	// Now, let's get some additional documents in so we can do some more
	// interesting stuff using a IF_DataVector.  The documents we are
	// interested in searching are the CD music documents.
	// They have the following format:

	// <?xml version="1.0"?>
	// <disc>
	// 	<id>00097210</id>
	// 	<length>2420</length>
	// 	<title>Frank Sinatra / Blue skies</title>
	// 	<genre>cddb/jazz</genre>
	// 	<track index="1" offset="150">blue skies</track>
	// 	.
	// 	.
	// 	.
	// </disc>

	if( RC_BAD( rc = pDb->transBegin( XFLM_UPDATE_TRANS, FLM_NO_TIMEOUT)))
	{
		goto Exit;
	}
	bTranStarted = TRUE;

	// We will first need an input file stream.

	uiLoop = 0;
	while( f_strlen( ppszPath[ uiLoop]))
	{
		if( RC_BAD( rc = pDbSystem->openFileIStream( 
			ppszPath[ uiLoop], &pIStream)))
		{
			goto Exit;
		}
		
		if( RC_BAD( rc = pDb->import( pIStream, XFLM_DATA_COLLECTION)))
		{
			goto Exit;
		}
		
		uiLoop++;
	}

	// Commit the transaction

	if( RC_BAD( rc = pDb->transCommit()))
	{
		goto Exit;
	}
	bTranStarted = FALSE;

	// Let's get some IF_DataVectors to work with.

	if( RC_BAD( rc = pDb->transBegin( XFLM_READ_TRANS, 0)))
	{
		goto Exit;
	}
	bTranStarted = TRUE;

	if (RC_BAD( rc = pDbSystem->createIFDataVector( &pFromKeyV)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pDbSystem->createIFDataVector( &pUntilKeyV)))
	{
		goto Exit;
	}

	// We need to get the index.

	// Now to search	the index above for all document titles in the index and
	// display the document Id and title for each node.  Note that the index
	// number is known to be 1.

	if (RC_BAD( rc = pDb->keyRetrieve( uiIndex, NULL, XFLM_FIRST, pFromKeyV)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pDb->keyRetrieve( uiIndex, NULL, XFLM_LAST, pUntilKeyV)))
	{
		goto Exit;
	}

	// Save the UntilKey value to compare with later.

	if (RC_BAD( rc = pUntilKeyV->outputKey( pDb, uiIndex, FALSE,
		&ucUntilKeyBuf[0], XFLM_MAX_KEY_SIZE, &uiUntilKeyLen)))
	{
		goto Exit;
	}

	for (;;)
	{
		// Display the current Document Id and the title.

		ui64DocId = pFromKeyV->getDocumentID();

		uiTitleLen = sizeof(ucTitle);
		if (RC_BAD( rc = pFromKeyV->getUTF8( 0, 
			(FLMBYTE *)&ucTitle[0], &uiTitleLen)))
		{
			goto Exit;
		}

		f_sprintf( (char *)&ucMsgBuf[0], "DocId: %"UI64FormatStr"\n%s\n",
			ui64DocId, ucTitle);
		printMessage( (char *)&ucMsgBuf[0]);

		// Check to see if this key matches the last or UntilKeyV value.

		if (RC_BAD( rc = pFromKeyV->outputKey( pDb, uiIndex, FALSE,
			&ucCurrentKeyBuf[0], XFLM_MAX_KEY_SIZE, &uiCurrentKeyLen)))
		{
			goto Exit;
		}

		if (uiCurrentKeyLen == uiUntilKeyLen)
		{
			if( f_memcmp( ucCurrentKeyBuf, ucUntilKeyBuf, uiCurrentKeyLen) == 0)
			{
				// We are done!

				break;
			}
		}

		// Get the next key.

		if (RC_BAD( rc = pDb->keyRetrieve( uiIndex, pFromKeyV,
			XFLM_EXCL, pFromKeyV)))
		{
			goto Exit;
		}
	}

	if( RC_BAD( rc = pDb->transCommit()))
	{
		goto Exit;
	}
	bTranStarted = FALSE;

	// Close the database

	pDb->Release();
	pDb = NULL;

	// Close all unused files

	if( RC_BAD( rc = pDbSystem->closeUnusedFiles( 0)))
	{
		goto Exit;
	}

	// Re-open the database

	if( RC_BAD( rc = pDbSystem->dbOpen( DB_NAME_STR, NULL, 
		NULL, NULL, FALSE, &pDb)))
	{
		goto Exit;
	}

	// Backup the database

	if( RC_BAD( rc = pDb->backupBegin( XFLM_FULL_BACKUP, XFLM_READ_TRANS,
		0, &pBackup)))
	{
		goto Exit;
	}

	if( RC_BAD( rc = pBackup->backup( BACKUP_NAME_STR, NULL, NULL, NULL, NULL)))
	{
		goto Exit;
	}

	if (RC_BAD( rc = pBackup->endBackup()))
	{
		goto Exit;
	}

	pBackup->Release();
	pBackup = NULL;

	// Close the database again

	pDb->Release();
	pDb = NULL;

	if( RC_BAD( rc = pDbSystem->closeUnusedFiles( 0)))
	{
		goto Exit;
	}

	// Remove the database

	if( RC_BAD( rc = pDbSystem->dbRemove( DB_NAME_STR, NULL, NULL, TRUE)))
	{
		goto Exit;
	}

	// Restore the database

	if( RC_BAD( rc = pDbSystem->dbRestore( DB_NAME_STR, NULL, NULL,
		BACKUP_NAME_STR, NULL, NULL, NULL)))
	{
		goto Exit;
	}

	// Rename the database

	if( RC_BAD( rc = pDbSystem->dbRename( DB_NAME_STR, NULL, NULL,
			NEW_NAME_STR, TRUE, NULL)))
	{
		goto Exit;
	}

	// Copy the database

	if( RC_BAD( rc = pDbSystem->dbCopy( NEW_NAME_STR, NULL, NULL,
		DB_NAME_STR, NULL, NULL, NULL)))
	{
		goto Exit;
	}

	// Remove the new database

	if( RC_BAD( rc = pDbSystem->dbRemove( NEW_NAME_STR, NULL, NULL, TRUE)))
	{
		goto Exit;
	}


Exit:

	if (bTranStarted && pDb)
	{
		(void)pDb->transAbort();
	}

	if (pCdChild)
	{
		pCdChild->Release();
	}

	if (pCdElement)
	{
		pCdElement->Release();
	}

	if( pMusicElement)
	{
		pMusicElement->Release();
	}

	if (pCdAttr)
	{
		pCdAttr->Release();
	}

	if (pTrackNode)
	{
		pTrackNode->Release();
	}

	if( pTmpNode)
	{
		pTmpNode->Release();
	}

	if (pQuery)
	{
		pQuery->Release();
	}

	if( pPosIStream)
	{
		pPosIStream->Release();
	}

	if (pIStream)
	{
		pIStream->Release();
	}

	if (pFromKeyV)
	{
		pFromKeyV->Release();
	}

	if (pUntilKeyV)
	{
		pUntilKeyV->Release();
	}

	if( pBackup)
	{
		pBackup->Release();
	}

	// Close the database object

	if( pDb)
	{
		pDb->Release();
	}

	if( RC_BAD( rc))
	{
		f_sprintf( (char *)ucMsgBuf, "Error 0x%04X\n",
											(unsigned)rc);
		printMessage( (char *)ucMsgBuf);
	}

	if( pDbSystem)
	{
		pDbSystem->Release();
	}

	return( 0);
}