diff options
| author | Ben Winston | 2024-06-07 23:05:19 -0400 |
|---|---|---|
| committer | Ben Winston | 2024-06-07 23:05:19 -0400 |
| commit | 1a7ee1a66cb0878189ee3f2b31d3ef4a48bfd63a (patch) | |
| tree | 223b3f99a5156d15be8ebf3520dac4f2b2586644 /booki.c | |
| parent | 0f7d71e15e2671125330dbea0104ac58b9353188 (diff) | |
when adding a new book, use the defined fields
Diffstat (limited to 'booki.c')
| -rw-r--r-- | booki.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -959,14 +959,21 @@ void add(char *booki_file) { // load an empty book to the edit file fputs("[[books]]\n", edit_file); - fputs("#isbn = \"\"\n", edit_file); - fputs("title = \"\"\n", edit_file); - fputs("author = \"\"\n", edit_file); - fputs("#pages = 0\n", edit_file); - fputs("#published = 0\n", edit_file); - fputs("language = \"English\"\n", edit_file); - fputs("#translator = \"\"\n", edit_file); - fputs("#on = \"\"\n", edit_file); + DataField datafield; + for (int i = 0; i < BOOK_FIELDS_COUNT; i++) { + datafield = BOOK_FIELDS[i]; + // skip ID for new books + if (ATTR_MATCH(datafield.name, "id")) + continue; + // otherwise, always write the name first + fputs(datafield.name, edit_file); + if (datafield.type == booki_string) + fputs(" = \"\"\n", edit_file); + else if (datafield.type == booki_number) + fputs(" = 0\n", edit_file); + else + fputs(" = ?\n", edit_file); + } fputs("\n", edit_file); // open the file for editing |
