Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. void IMPLEMENT(PrintFormat_loadFromFile)(PrintFormat * format, const char * filename)
  2. {
  3. char * Tmp;
  4. char * old;
  5. FILE * file;
  6.  
  7. file = fopen(filename,"r");
  8. if (file == NULL)
  9. fatalError("the file can't be read");
  10. PrintFormat_finalize(format);
  11.  
  12.  
  13. format->name = duplicateString(readLine(file)+6);
  14. format->name[stringLength(format->name)-1] = '\0';
  15.  
  16. if (compareString(readLine(file) ,".HEADER\n") != 0)
  17. fatalError("the file structure is compromised");
  18. Tmp = readLine(file);
  19. format->header = duplicateString("");
  20. while (compareString(Tmp, ".ROW\n") != 0)
  21. {
  22. old = format->header;
  23. format->header = concatenateString(old, Tmp);
  24. free(old);
  25. free(Tmp);
  26. Tmp = readLine(file);
  27. }
  28. format->header[stringLength(format->header)-1] = '\0';
  29.  
  30. format->row = duplicateString("");
  31. Tmp = readLine(file);
  32. while (compareString(Tmp, ".FOOTER\n") != 0)
  33. {
  34. old = format->row;
  35. format->row = concatenateString(old, Tmp);
  36. free(old);
  37. free(Tmp);
  38. Tmp = readLine(file);
  39. }
  40. format->row[stringLength(format->row)-1] = '\0';
  41. format->footer = duplicateString("");
  42. Tmp = readLine(file);
  43. while (compareString(Tmp, ".END") != 0)
  44. {
  45. old = format->footer;
  46. format->footer = concatenateString(old, Tmp);
  47. free(old);
  48. free(Tmp);
  49. Tmp = readLine(file);
  50. }
  51. format->footer[stringLength(format->footer)-1] = '\0';
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement