diff options
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 | 
