+ char line[MAX_CLUE_LENGTH+10];
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ p.grid_size = atoi (line);
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ p.grid_frozen = atoi (line) == 0 ? false : true ;
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ if (strlen (line) != 1)
+ strcpy (p.hashed_password, strtok (line, "\n"));
+ else
+ strcpy (p.hashed_password, "\0");
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ if (strlen (line) != 1)
+ strcpy (p.salt, strtok (line, "\n"));
+ else
+ strcpy (p.salt, "\0");
+
+ /* read each character of the grid */
+ for (int i = 0; i < p.grid_size; i ++ )
+ {
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ for (int j = 0; j < p.grid_size; j ++)
+ p.chars[i][j] = line[j];
+ }
+ /* read the word numbers */
+ for (int i = 0; i < p.grid_size; i ++)
+ {
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ char *token = strtok (line, " ");
+ for (int j = 0; j < p.grid_size; j ++)
+ {
+ if (token != NULL)
+ p.start_across_word[i][j] = atoi (token);
+ token = strtok (NULL, " ");
+ if (token != NULL)
+ p.start_down_word[i][j] = atoi (token);
+ token = strtok (NULL, " ");
+ }
+ }
+ /* read the clues */
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+
+ /* across clues */
+ char clues[100][MAX_CLUE_LENGTH];
+ int word_num[100];
+ int c = 0;
+ /* first read the across clues from file */
+ while (1)
+ {
+ fgets (line, MAX_CLUE_LENGTH + 10, infile);
+ /* if reached the end of across clues */
+ if (strcmp (line, "DOWN\n") == 0)
+ break;
+ word_num[c] = atoi (strtok (line, "\t"));
+ char *cl = strtok (NULL, "\n");
+ if (cl != NULL)
+ strcpy (clues[c], cl);
+ else
+ strcpy (clues[c], "\0");
+ c++;
+ }
+ /* set the clue to the correct cell in grid */
+ for (int i = 0; i < p.grid_size; i ++)
+ {
+ for (int j = 0; j < p.grid_size; j ++)
+ {
+ for (int r = 0; r < c; r ++)
+ if (p.start_across_word[i][j] == word_num[r])
+ strcpy (p.clue_across[i][j], clues[r]);
+ }
+ }
+
+ /* down clues */
+ c = 0;
+ while (fgets (line, MAX_CLUE_LENGTH + 10, infile))
+ {
+ word_num[c] = atoi (strtok (line, "\t"));
+ char* cl = strtok (NULL, "\n");
+ if (cl != NULL)
+ strcpy (clues[c], cl);
+ else
+ strcpy (clues[c], "\0");
+ c++;
+ }
+ for (int i = 0; i < p.grid_size; i ++)
+ {
+ for (int j = 0; j < p.grid_size; j ++)
+ {
+ for (int r = 0; r < c; r ++)
+ if (p.start_down_word[i][j] == word_num[r])
+ strcpy (p.clue_down[i][j], clues[r]);
+ }
+ }
+