Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void IMPLEMENT(PrintFormat_loadFromFile)(PrintFormat * format, const char * filename)
- {
- char * Tmp;
- char * old;
- FILE * file;
- file = fopen(filename,"r");
- if (file == NULL)
- fatalError("the file can't be read");
- PrintFormat_finalize(format);
- format->name = duplicateString(readLine(file)+6);
- format->name[stringLength(format->name)-1] = '\0';
- if (compareString(readLine(file) ,".HEADER\n") != 0)
- fatalError("the file structure is compromised");
- Tmp = readLine(file);
- format->header = duplicateString("");
- while (compareString(Tmp, ".ROW\n") != 0)
- {
- old = format->header;
- format->header = concatenateString(old, Tmp);
- free(old);
- free(Tmp);
- Tmp = readLine(file);
- }
- format->header[stringLength(format->header)-1] = '\0';
- format->row = duplicateString("");
- Tmp = readLine(file);
- while (compareString(Tmp, ".FOOTER\n") != 0)
- {
- old = format->row;
- format->row = concatenateString(old, Tmp);
- free(old);
- free(Tmp);
- Tmp = readLine(file);
- }
- format->row[stringLength(format->row)-1] = '\0';
- format->footer = duplicateString("");
- Tmp = readLine(file);
- while (compareString(Tmp, ".END") != 0)
- {
- old = format->footer;
- format->footer = concatenateString(old, Tmp);
- free(old);
- free(Tmp);
- Tmp = readLine(file);
- }
- format->footer[stringLength(format->footer)-1] = '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement