-extern uint8_t read_winconf_from_file(char * line, uint32_t linemax,
- FILE * file)
-{
- char * f_name = "read_winconf_from_file()";
- int test = try_fgetc(file, f_name);
- if (EOF == test)
- {
- return 0;
- }
- struct Win win;
- memset(&win, 0, sizeof(struct Win));
- win.id = (char) test;
- try_fgetc(file, f_name);
- try_fgets(line, linemax + 1, file, f_name);
- win.title = try_malloc(strlen(line), f_name);
- memcpy(win.title, line, strlen(line) - 1); /* Eliminate newline char */
- win.title[strlen(line) - 1] = '\0'; /* char at end of string. */
- try_fgets(line, linemax + 1, file, f_name);
- win.target_height = atoi(line);
- win.target_height_type = (0 >= win.target_height);
- try_fgets(line, linemax + 1, file, f_name);
- win.target_width = atoi(line);
- win.target_width_type = (0 >= win.target_width);
- read_keybindings_from_file(line, linemax, file, &win.kb);
- add_win_to_windb(&win);
- return 1;
-}
-
-
-
-extern void write_winconf_of_id_to_file(FILE * file, char c, char * delim)
-{
- char * f_name = "write_winconf_of_id_to_file()";
- struct Win * wc = get_win_by_id(c);
- uint8_t size = strlen(wc->title) + 2;
- if (size < 7) /* Ensure that at least 5 + 2 char fit into line so that */
- { /* the digit representation of any uint16_t may be stored. */
- size = 7;
- }
- char line[size];
- sprintf(line, "%c\n", wc->id);
- try_fwrite(line, sizeof(char), strlen(line), file, f_name);
- sprintf(line, "%s\n", wc->title);
- try_fwrite(line, sizeof(char), strlen(line), file, f_name);
- sprintf(line, "%d\n", wc->target_height);
- try_fwrite(line, sizeof(char), strlen(line), file, f_name);
- sprintf(line, "%d\n", wc->target_width);
- try_fwrite(line, sizeof(char), strlen(line), file, f_name);
- write_keybindings_to_file(file, &wc->kb, delim);
-}
-
-
-
-extern void read_order_wins_visible_active(char * line, uint32_t linemax,
- FILE * file)
-{
- char * f_name = "read_order_wins_visible_active()";
- char win_order[linemax + 1];
- try_fgets(win_order, linemax + 1, file, f_name);
- win_order[strlen(win_order) - 1] = '\0';
- world.windb.order = try_malloc(strlen(win_order) + 1, f_name);
- sprintf(world.windb.order, "%s", win_order);
- int char_or_eof = try_fgetc(file, f_name);
- char * err_eof = "fgetc() unexpectedly hitting EOF";
- exit_trouble(EOF == char_or_eof, f_name, err_eof);
- world.windb.active = (uint8_t) char_or_eof;
- exit_trouble(EOF == try_fgetc(file, f_name), f_name, err_eof);
- try_fgets(line, linemax + 1, file, f_name);
-}
-
-
-
-extern void write_order_wins_visible_active(FILE * file, char * delim)
-{
- char * f_name = "write_order_wins_visible_active()";
- try_fwrite(world.windb.order, strlen(world.windb.order), 1, file, f_name);
- try_fputc('\n', file, f_name);
- try_fputc(world.windb.active, file, f_name);
- try_fputc('\n', file, f_name);
- try_fwrite(delim, strlen(delim), 1, file, f_name);
-}
-
-
-