summaryrefslogtreecommitdiff
path: root/src/note.c
AgeCommit message (Collapse)Author
2012-02-19Fix hash table issues with ISO C99Lukas Fleischer
ISO C99 forbids unnamed structs/unions and nested functions. Move the "HTABLE_HEAD" and "HTABLE_GENERATE" parts out of the function body and place them at the very top of the file (where function definitions are allowed). Also, remove the unnamed struct from "htable.h" (which was useless anyway). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-18Fix up strncat() usageLukas Fleischer
The last argument to strncat() should not be the total buffer length; it should be the space remaining: The strncat() function shall append not more than n bytes (a null byte and bytes that follow it are not appended) from the array pointed to by s2 to the end of the string pointed to by s1. The initial byte of s2 overwrites the null byte at the end of s1. A terminating null byte is always appended to the result. This patch fixes a couple of potential buffer overflow vulnerabilities. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-01-17Split note file generation into separate functionLukas Fleischer
We currently use this in one place only but might reuse this a couple of times later (when migrating to libical). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02Do not cast unused return values to voidLukas Fleischer
A small style fix that removes all remaining "(void)" casts. Using these isn't encouraged in GNU coding guidelines and doesn't serve a certain purpose, except for satisfying a few static code analysis tools. We already nuked some of these in previous patches, but this semantic patch should fix what's left: @@ identifier func; @@ - (void)func ( + func ( ...); Long lines were re-formatted manually. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05Add a garbage collector for note filesLukas Fleischer
Now that we use hashes to identify notes, a garbage collector comes in handy. We search for note files that aren't referenced anywhere. Such files might come up if a note, that isn't connected with any other item, is edited. Huge parts of this code are very hackish due to our data structure layout and the way our hash table implementation works. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05Do not unlink() note files on note removalLukas Fleischer
Now that we use hash-based note file names, note files should never be unlinked as a note file might be shared. Also, remove the ERASE_FORCE_KEEP_NOTE flag that no longer makes any sense. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05Use hash-bashed file names in edit_note()Lukas Fleischer
Note file names are now generated based on their content. Items using the same note will share a single note file. Please note that this implies a few changes: * Both random-style and hash-style note files need to be handled to ensure we do not break backwards compatibility. * Note files may not be moved or deleted if a note is changed or removed since the original note file might be used by another item as well. * A garbage collector to remove unreferenced note files needs to be implemented. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05Accept variable length note namesLukas Fleischer
Read up to the first blank in note_read() instead of assuming a fixed-width note file name. Accept everything up to 40 characters (which is the length of a SHA1 hash in hexadecimal representation). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-05Refactor out note deserializationLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-21Refactor out note functionsLukas Fleischer
* Add new note_edit() and note_view() helper functions. Use these instead of copy-pasted code in *_note_edit(). * Move all note-related functions (note_edit(), note_view(), note_erase()) to a new source file "note.c". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>