// Mode: -*- C++ -*- /* * Copyright 1985,1986,1987,1988,1989,1990,1991,1992,1993 * by Microelectronics and Computer Technology Corporation (MCC) * All Rights Reserved * * MCC/CARNOT CONFIDENTIAL AND PROPRIETARY * ************************************************************** */ /* * %Header% * * %Log% */ static const char *rcsid = "%Header%"; #include #include #include // Make sure that the name is not mangled extern "C" { LdlStatus print_header(LdlObject source, LdlObject destination, LdlObject no_of_options); LdlStatus print_result(LdlObject agent, LdlObject mileage, LdlObject transit_list, LdlObject flight_list); } LdlStatus print_header(LdlObject source, LdlObject destination, LdlObject no_of_options) { LdlStatus status = LDL_FAIL; if (ldl_entry_p()) { if (ldl_string_p(source) && ldl_string_p(destination) && ldl_int_p(no_of_options)) { char* source_str; char* destination_str; int no_of_options_value; if ((source_str = ldl_get_string(source)) && (destination_str = ldl_get_string(destination)) && (no_of_options_value = ldl_get_int(no_of_options))) { fprintf(stdout, "\n\nSource: %s\tDestination: %s\tNumber of Options: %d", source_str, destination_str, no_of_options_value); fprintf(stdout, "\n\nAgent\t\tMileage\tTransits / Flights"); fprintf(stdout, "\n------------------------------------------------------------------\n"); fflush(stdout); status = LDL_SUCCESS; } else cerr << "\nExternal Error (print_header): Can not get arg values" << endl; } else cerr << "\nExternal Error (print_header): Illegal arg types" << endl; } return(status); } static void print_list(LdlObject ldl_list) { register int i; int size = ldl_get_list_length(ldl_list); LdlObject element; char* element_str; for (i = 0; i < size; i++) { if ((element = ldl_get_list_nth_element(ldl_list, i)) && (ldl_string_p(element)) && (element_str = ldl_get_string(element))) { fprintf(stdout, "%s", element_str); fflush(stdout); if (i + 1 < size) { fprintf(stdout, ", "); fflush(stdout); } } else cerr << "\nExternal Error (print_list): Wrong list element types : " << i << endl; } } LdlStatus print_result(LdlObject agent, LdlObject mileage, LdlObject transit_list, LdlObject flight_list) { LdlStatus status = LDL_FAIL; if (ldl_entry_p()) { if (ldl_string_p(agent) && ldl_int_p(mileage) && ldl_list_p(transit_list) && ldl_list_p(flight_list)) { char* agent_str; int mileage_value; if ((agent_str = ldl_get_string(agent)) && (mileage_value = ldl_get_int(mileage))) { fprintf(stdout, "\n%s\t%d\t", agent_str, mileage_value); fflush(stdout); if (ldl_get_list_length(transit_list)) print_list(transit_list); else fprintf(stdout, "(Direct Flight)"); fprintf(stdout, "\n\t\t\t"); fflush(stdout); print_list(flight_list); fprintf(stdout, "\n"); fflush(stdout); status = LDL_SUCCESS; } else cerr << "\nExternal Error (print_result): Can not get arg values" << endl; } else cerr << "\nExternal Error (print_result): Illegal arg types" << endl; } return(status); }