Go to the source code of this file.
Functions | |
| void | command_merge (int argc, int last_arg, const char **argv) |
| Parses command-line for merge options and performs merge command. | |
|
||||||||||||||||
|
Parses command-line for merge options and performs merge command. Performs merge command functionality.
00345 { PROFILE(COMMAND_MERGE);
00346
00347 int i; /* Loop iterator */
00348 unsigned int rv; /* Return value from snprintf calls */
00349 bool error = FALSE;
00350
00351 /* Output header information */
00352 rv = snprintf( user_msg, USER_MSG_LENGTH, COVERED_HEADER );
00353 assert( rv < USER_MSG_LENGTH );
00354 print_output( user_msg, NORMAL, __FILE__, __LINE__ );
00355
00356 Try {
00357
00358 str_link* strl;
00359 bool stop_merging;
00360 int curr_leading_hier_num = 0;
00361
00362 /* Parse score command-line */
00363 if( !merge_parse_args( argc, last_arg, argv ) ) {
00364
00365 /* Read in base database */
00366 rv = snprintf( user_msg, USER_MSG_LENGTH, "Reading CDD file \"%s\"", merge_in_head->str );
00367 assert( rv < USER_MSG_LENGTH );
00368 print_output( user_msg, NORMAL, __FILE__, __LINE__ );
00369 db_read( merge_in_head->str, READ_MODE_MERGE_NO_MERGE );
00370
00371 /* If the currently read CDD didn't contain any merged CDDs it is a leaf CDD so mark it as such */
00372 if( (db_list[curr_db]->leading_hier_num - curr_leading_hier_num) == 1 ) {
00373 merge_in_head->suppl = 1;
00374 }
00375 curr_leading_hier_num = db_list[curr_db]->leading_hier_num;
00376
00377 /* Read in databases to merge */
00378 strl = merge_in_head->next;
00379 stop_merging = (strl == merge_in_head);
00380 while( (strl != NULL) && !stop_merging ) {
00381 rv = snprintf( user_msg, USER_MSG_LENGTH, "Merging CDD file \"%s\"", strl->str );
00382 assert( rv < USER_MSG_LENGTH );
00383 print_output( user_msg, NORMAL, __FILE__, __LINE__ );
00384 db_read( strl->str, READ_MODE_MERGE_NO_MERGE );
00385
00386 /* If we have not merged any CDD files from this CDD, this is a leaf CDD so mark it as such */
00387 if( (db_list[curr_db]->leading_hier_num - curr_leading_hier_num) == 1 ) {
00388 strl->suppl = 1;
00389 }
00390 curr_leading_hier_num = db_list[curr_db]->leading_hier_num;
00391
00392 stop_merging = (strl == merge_in_cl_last);
00393 strl = strl->next;
00394 }
00395
00396 /* Perform the tree merges */
00397 db_merge_instance_trees();
00398
00399 /* Bind */
00400 bind_perform( TRUE, 0 );
00401
00402 /* Write out new database to output file */
00403 db_write( merged_file, FALSE, TRUE, FALSE );
00404
00405 print_output( "\n*** Merging completed successfully! ***", NORMAL, __FILE__, __LINE__ );
00406
00407 }
00408
00409 } Catch_anonymous {
00410 error = TRUE;
00411 }
00412
00413 /* Close database */
00414 db_close();
00415
00416 /* Deallocate other memory */
00417 str_link_delete_list( merge_in_head );
00418 free_safe( merged_file, (strlen( merged_file ) + 1) );
00419
00420 if( error ) {
00421 Throw 0;
00422 }
00423
00424 PROFILE_END;
00425
00426 }
|
1.3.4