Пример #1
0
//------------------------------------------------------------
//------------------------------------------------------------
static void
writeSGML(BookCaseDB &db,
	  const char *thisBook,
	  DBCursor &sgml_cursor,
	  hashTable<CC_String,BTCollectable> &hd)
{
  DBTable *out = db.DB::table(DATABASE_STDIO,
			      SGML_CONTENT_CODE, 2,
			      DB::CREATE);

  const char *aBook;
  const char *nodeLoc;
  size_t dataLen;
  const char *data;
  char *bufptr;		// Walk through SGML data stream and update LAST fields
  char *nevermind;	// We don't care about the return value from the parse

  while(sgml_cursor.next(STRING_CODE, &aBook,
		    STRING_CODE, &nodeLoc,
		    -STRING_CODE, &data, &dataLen,
		    NULL)){

    if(strcmp(aBook, thisBook) != 0){ /* book id has changed! We're done... */
      sgml_cursor.undoNext();
      break;
    }

#ifdef FISH_DEBUG
    DBUG_PRINT("SGML", ("SGML data for: ::%s `%.40s...' \n",
			nodeLoc, data));
#endif

    FlexBuffer new_node_buffer;
    
    bufptr = (char *) data;
    nevermind = parse4last( bufptr );

    insert_remotelink( &hd, (char *)data, dataLen, &new_node_buffer);
    
    out->insert_untagged(STRING_CODE, nodeLoc,
			 -STRING_CODE,
			 new_node_buffer.GetBuffer(),
			 new_node_buffer.GetSize(),
			 NULL);
  }

  delete out;
}
Пример #2
0
//------------------------------------------------------------
static void
writeDLP(BookCaseDB &db, info_lib *mmdb,
	 const char *bcname,
	 const char *thisBook,
	 DBCursor &dlp_cursor,
	 hashTable<CC_String,BTCollectable> &node_tab)
{
  DBTable *out = db.DB::table(DATABASE_STDIO,
			      DLP_CODE, 1,
			      DB::CREATE);

  const char *aBook;
  const char *nodeLoc;
  int   line_num;
  const char *toc_file_name;

  hashTable<CC_String, int> link_table(hash_func);
  
  int record_pos = dlp_cursor.tell();
  
  // create the link table  
  while(dlp_cursor.next(STRING_CODE, &aBook,
			STRING_CODE, &nodeLoc,
			INTEGER_CODE, &line_num,
			STRING_CODE,  &toc_file_name,
			NULL)){
    
    if(strcmp(aBook, thisBook) != 0){ /* book id has changed! We're done... */
      dlp_cursor.undoNext();
      break;
    }

    CC_String *key = new CC_String ( nodeLoc );
    link_table.insertKeyAndValue( key, new int(line_num) );
      
#ifdef FISH_DEBUG
    // DBUG_PRINT("DLP", ("DLP Entry: O:%s\n", nodeOID));
#endif
  }

  checkTocLink( toc_file_name, link_table, node_tab ); /* throw exception if
							  unresolved TOC links
							  are found */
  link_table.clearAndDestroy();
  
  dlp_cursor.seekToRec( record_pos );
  out->start_list();
  while ( dlp_cursor.next( STRING_CODE, &aBook,
			   STRING_CODE, &nodeLoc,
			   INTEGER_CODE, &line_num,
			   STRING_CODE, &toc_file_name,
			   NULL)) {

    if(strcmp(aBook, thisBook) != 0){ /* book id has changed! We're done... */
      dlp_cursor.undoNext();
      break;
    }
    const char *nodeOID = to_oid(mmdb, bcname, nodeLoc);
    out->insert_untagged(OID_CODE, nodeOID,
			   NULL);
#ifdef FISH_DEBUG
    DBUG_PRINT("DLP", ("DLP Entry: O:%s\n", nodeOID));
#endif
  }

  out->end_list();

  /* exception thrown in this if failed */
  delete out;
  
}