Exemple #1
0
//------------------------------------------------------------
static void
writeTOC(BookCaseDB &db,
	 info_lib *mmdb,
	 const char *bcname,
	 const char *thisBook,
	 DBCursor &toc_cursor )
{
  DBTable *out = db.DB::table(DATABASE_STDIO,
			      TOC_CODE, NUM_TOC_FIELDS,
			      DB::CREATE);
  const char *aBook;
  const char *nodeLoc;
  const char *parent;
  int childQty;
  char **children;
  int treeSize;
  
  while(toc_cursor.next(STRING_CODE, &aBook,
			STRING_CODE, &nodeLoc,
			STRING_CODE, &parent,
			SHORT_LIST_CODE, &childQty, STRING_CODE, &children,
			INTEGER_CODE, &treeSize,
			NULL)){
    StringList heap;
    
    if(strcmp(aBook, thisBook) != 0){ /* book id has changed! We're done... */
      toc_cursor.undoNext();
      break;
    }

    for(int i = 0; i < childQty; i++){
      heap.append(to_oid(mmdb, bcname, children[i]));
    }
    
    const char *nodeOID = heap.append(to_oid(mmdb, bcname, nodeLoc));
    const char *parentOID = heap.append(to_oid(mmdb, bcname, parent));
    
#ifdef FISH_DEBUG
    DBUG_PRINT("TOC", ("TOC Entry: O:%s treesize: %d\n", nodeOID, treeSize));
#endif
    
    out->insert(OID_CODE, nodeOID,
		OID_CODE, parentOID,
		INTEGER_CODE, treeSize,
		/* first childQty strings in heap are oids for children */
		OID_LIST_CODE, childQty, heap.array(),
		NULL);
  }

  delete out;
}
Exemple #2
0
void StyleTaskDB::done(const char * name,
		  const char * online, int online_len,
		  const char * print, int print_len)
{
  /*
   * Use -STRING_CODE instead of STRING_CODE to handle 8-bit clean
   * data
   */
  
  DBTable *tbl = f_bookcase->table(BookCaseDB::StyleSheet);
  
  tbl->insert(STRING_CODE, name,
	      -STRING_CODE, online, (size_t)online_len,
	      -STRING_CODE, print,  (size_t)print_len,
	      NULL);

  reset();
}
Exemple #3
0
//------------------------------------------------------------
static void
writeLCF(BookCaseDB& db, info_lib *mmdb,
	 const char *bcname,
	 hashTable<CC_String,BTCollectable> &hd)
{

  DBTable *out = db.DB::table(DATABASE_STDIO,
			      LOCATOR_CODE, BT_NUM_LOCATOR_FIELDS,
			      DB::CREATE);
  
  hashTableIterator<CC_String,BTCollectable> loc_it( hd );

  while ( ++loc_it ) {
    CC_String *locator_str = ( CC_String *)loc_it.key();
    const char *locator = (const char *)*locator_str;

    BTCollectable *loc_val = ( BTCollectable *)loc_it.value();
    const char *opaque, *nodeloc;
    char* reflabel;
    nodeloc = opaque = (const char *)loc_val->get_value();
    reflabel = strchr(opaque, '\t');
    *reflabel++ = 0;
    
    const char *nodeOID = to_oid(mmdb, bcname, nodeloc);
    
#ifdef FISH_DEBUG
    DBUG_PRINT("LCF", ("LCF entry: L:%s->O:%s\n",
		       locator, nodeOID));
#endif
    out->insert(STRING_CODE, locator,
		OID_CODE, nodeOID,
		STRING_CODE, reflabel,
		NULL);
    
  }

  delete out;
  
}
Exemple #4
0
//------------------------------------------------------------
static void
writeGraphics(BookCaseDB &db, const char *thisBook, DBCursor &gr_cursor,
	      int compressed, char *comp_agent)
{
  DBTable *out = db.DB::table(DATABASE_STDIO,
			      GRAPHIC_CODE, BT_NUM_GRAPHIC_FIELDS,
			      DB::CREATE);

  const char *aBook;
  const char *gid;
  const char *name;
  const char *version;
  const char *typeInfo;
  const char *data;
  int len;
  const char *title;
  
  while(gr_cursor.next(STRING_CODE, &aBook,
		       STRING_CODE, &gid,
		       STRING_CODE, &name,
		       STRING_CODE, &version,
		       STRING_CODE, &typeInfo,
		       -STRING_CODE, &data, &len,
		       STRING_CODE, &title,
		       NULL)){


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

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

    if ( typeInfo[0] - '0'  == GR_TYPE_POSTSCRIPT &&
	 compressed ) {

      out->insert(STRING_CODE, gid,
		  STRING_CODE, name,
		  STRING_CODE, version,
		  STRING_CODE, typeInfo,
		  -COMPRESSED_STRING_CODE, comp_agent, data, len,
		  STRING_CODE, title,
		  NULL);
    }
    else {
      out->insert(STRING_CODE, gid,
		  STRING_CODE, name,
		  STRING_CODE, version,
		  STRING_CODE, typeInfo,
		  -STRING_CODE, data, len,
		  STRING_CODE, title,
		  NULL);
    }
  }

  delete out;

}
Exemple #5
0
//------------------------------------------------------------
static void
writeCCF(BookCaseDB& db,
	 info_lib *mmdb,
	 const char *bcname )
{

  DBTable *bookMeta = db.table(BookCaseDB::BookMeta, DB::READ);
  DBCursor cursor(*bookMeta);
  DBTable *ccf = db.DB::table(DATABASE_STDIO,
			      DOC_CODE, BT_NUM_DOC_FIELDS,
			      DB::CREATE);

  const char *bookLocator;
  const char *stitle;
  const char *title;
  int seq_no;
  int tabQty;
  const char **tabLines;
  const char *access;

  /*
   * First put the global node table into hash dictionary
   */

  hashTable<CC_String,BTCollectable> global_node_tab(hash_func);
  create_node_dict( global_node_tab , db);  /* throw exception if duplicate
					   node locator is found */
  
  int exception_flag = 0;
  while(cursor.next(STRING_CODE, &bookLocator,
		    STRING_CODE, &stitle,
		    STRING_CODE, &title,
		    INTEGER_CODE, &seq_no,
		    SHORT_LIST_CODE, &tabQty, STRING_CODE, &tabLines,
		    STRING_CODE, &access,
		    NULL)){

    StringList heap;

    /* convert tab to oids in forst tabQty items in heap */
    for(int i = 0; i < tabQty; i++){

      char *t = (char *)tabLines[i];                   

      const char *name = strtok( t, "\t" );
      const char *loc  = strtok( NULL, "\t");
      const char *line = strtok( NULL, "\t");
      const char *file_name = strtok( NULL, "\t");

      int nameLen = strlen( name );

      /*
       * First check if the tab link is resolved
       */

      CC_String key ( loc );
      
      BTCollectable *tab_link = (BTCollectable *)global_node_tab.
	                                            findValue( &key );


      if ( !tab_link ) {
	cerr << "(ERROR)         Tab ID = " << loc << endl
	     << "               of book = " << title << endl
	     << "     specified in file = " << file_name << endl
	     << "               at line = " << line << endl
	     << "     is not pointing to any section ID found in the book\n\n";	
	exception_flag = 1;
      }
      else {
	/*
	 * see if it is a node locator within the same book
	 */
	if ( strcmp( tab_link->get_value(), bookLocator ))  {
	  cerr << "(ERROR)         Tab ID = " << loc << endl
	       << "               of book = " << title << endl
	       << "     specified in file = " << file_name << endl
	       << "               at line = " << line << endl
	       << "     is not pointing to any section ID found in the book\n\n";

	  exception_flag = 1;
	}
      }
	
      // if exception_flag is set, calling to_oid will throw exception
      // It will just loop through all the tabs, and report all the bad ones
      if ( !exception_flag ) {
	const char *tabOID = to_oid(mmdb, bcname, loc);
	char *result = new char[nameLen + 1 + strlen(tabOID) + 1];
	sprintf(result, "%s\t%s", name, tabOID );
	heap.add(result);
      }
    }

    if ( !exception_flag ) {
  
      const char *bookOID = heap.append(to_oid(mmdb, bcname, bookLocator));
      
#ifdef FISH_DEBUG
      DBUG_PRINT("CCF", ("Load Book: O:%s `%s'\n", bookOID, title));
#endif
    
      ccf->insert(OID_CODE, bookOID,
		  STRING_CODE, stitle,
		  STRING_CODE, title,
		  INTEGER_CODE, seq_no,
		  SHORT_LIST_CODE, tabQty, STRING_CODE, heap.array(),
		  STRING_CODE, access,
		  NULL);
    }
  }

  if ( exception_flag ) {
    throw(Unexpected("Tab validation failed"));
  }

  delete ccf;
  global_node_tab.clearAndDestroy();
}