Links/RB_CollectLinks [ Functions ]
FUNCTION
Convert header information into link information.
RB_header -> RB_link conversion
SYNOPSIS
void RB_CollectLinks( struct RB_Document *document, struct RB_header **headers, unsigned long count )
INPUTS
- document --
- headers -- the array with headers.
- count -- number of headers in the array
OUTPUT
- link_index -- an array with links
- link_index_size -- the number of links in the array.
SOURCE
{ unsigned long i, j; int k; struct RB_Part *i_part; for ( i = j = 0; i < count; ++i ) { j += headers[i]->no_names - 1; } link_index_size = count + j; if ( ( document->actions.do_multidoc ) && ! ( document->actions.do_one_file_per_header ) ) { for ( i_part = document->parts; i_part; i_part = i_part->next ) { if ( i_part->headers ) { link_index_size++; } } } link_index = ( struct RB_link ** ) calloc( link_index_size, sizeof( struct RB_link ** ) ); case_sensitive_link_index = ( struct RB_link ** ) calloc( link_index_size, sizeof( struct RB_link ** ) ); for ( i = j = 0; i < count; ++i ) { struct RB_link *link; struct RB_header *header; header = headers[i]; assert( header->unique_name ); assert( header->file_name ); for( k = 0; k < header->no_names; j++, k++ ) { link = RB_Alloc_Link( header->unique_name, function_name(header->names[k]), header->file_name ); link->htype = header->htype; link->is_internal = header->is_internal; link_index[j] = link; case_sensitive_link_index[j] = link; } } /* If we are in multidoc mode, we also create links * for all the source files. */ if ( ( document->actions.do_multidoc ) && /* but not for one file per header multidocs */ ! ( document->actions.do_one_file_per_header ) ) { for ( i_part = document->parts; i_part; i_part = i_part->next ) { if ( i_part->headers ) { struct RB_link *link; link = RB_Alloc_Link( "robo_top_of_doc", i_part->filename->name, RB_Get_FullDocname( i_part->filename ) ); i_part->filename->link = link; link->htype = RB_FindHeaderType( HT_SOURCEHEADERTYPE ); link_index[j] = link; case_sensitive_link_index[j] = link; ++j; } else { i_part->filename->link = NULL; } } } /* Sort all the links so we can use a binary search */ RB_QuickSort( (void **)link_index, 0, link_index_size - 1, link_cmp ); RB_QuickSort( (void **)case_sensitive_link_index, 0, link_index_size - 1, case_sensitive_link_cmp ); }