Petition PetitionManager::Load(const char *path, int id) { char buffer[256]; Util::SafeFormat(buffer, sizeof(buffer), "%s\\%d.txt", path, id); Platform::FixPaths(buffer); FileReader lfr; Petition newItem; if (lfr.OpenText(buffer) != Err_OK) { g_Log.AddMessageFormat("Could not open file [%s]", buffer); } else { lfr.CommentStyle = Comment_Semi; int r = 0; while (lfr.FileOpen() == true) { r = lfr.ReadLine(); lfr.SingleBreak("="); lfr.BlockToStringC(0, Case_Upper); if (r > 0) { if (strcmp(lfr.SecBuffer, "[ENTRY]") == 0) { // if (newItem.petitionId != 0) { g_Log.AddMessageFormat( "[WARNING] Petition file %s has more than one ENTRY", buffer); newItem.RunLoadDefaults(); break; } } else if (strcmp(lfr.SecBuffer, "ID") == 0) newItem.petitionId = lfr.BlockToIntC(1); else if (strcmp(lfr.SecBuffer, "SAGE") == 0) newItem.sageCDefID = lfr.BlockToIntC(1); else if (strcmp(lfr.SecBuffer, "PETITIONER") == 0) newItem.petitionerCDefID = lfr.BlockToIntC(1); else if (strcmp(lfr.SecBuffer, "TIMESTAMP") == 0) newItem.timestamp = lfr.BlockToULongC(1); else if (strcmp(lfr.SecBuffer, "CATEGORY") == 0) newItem.category = lfr.BlockToIntC(1); else if (strcmp(lfr.SecBuffer, "DESCRIPTION") == 0) { string r = lfr.BlockToStringC(1, 0); Util::ReplaceAll(r, "\\r\\n", "\r\n"); Util::ReplaceAll(r, "\\n", "\n"); Util::SafeCopy(newItem.description, r.c_str(), sizeof(newItem.description)); } else if (strcmp(lfr.SecBuffer, "RESOLUTION") == 0) { string r = lfr.BlockToStringC(1, 0); Util::ReplaceAll(r, "\\r\\n", "\r\n"); Util::ReplaceAll(r, "\\n", "\n"); Util::SafeCopy(newItem.resolution, r.c_str(), sizeof(newItem.resolution)); } else { g_Log.AddMessageFormat( "[WARNING] Petition file %s has unknown pair %s", buffer, lfr.SecBuffer); } } } } if (newItem.petitionId != 0) { newItem.RunLoadDefaults(); } return newItem; }