packing_main.c 675 B

12345678910111213141516171819202122232425262728293031
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include "packing.h"
  5. int main(int argc, char **argv){
  6. //check arguments
  7. if (argc != 3){
  8. printf("usage: ./proj4 <input_file> <output_file>\n");
  9. return EXIT_FAILURE;
  10. }
  11. // read data
  12. Node *root = load_file(argv[1]);
  13. if(root == NULL){ // check for error
  14. printf("File read error.");
  15. return EXIT_FAILURE;
  16. }
  17. double best_width = root->width;
  18. double best_height = root->height;
  19. find_best_fit(root, &best_width, &best_height);
  20. // save boxes
  21. save_boxes(argv[2], root);
  22. // clean up
  23. free_tree(root); // free memory
  24. return EXIT_SUCCESS; // exit
  25. }