aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* | Add configuration option to run the GC on exitLukas Fleischer2011-10-055-15/+40
| | | | | | | | | | | | | | | | If "auto_gc" is enabled, the garbage collector for note files will be run on every exit. As this is an experimental feature and may cause data loss, this is disabled by default. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a garbage collector for note filesLukas Fleischer2011-10-052-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Do not unlink() note files on note removalLukas Fleischer2011-10-058-64/+47
| | | | | | | | | | | | | | | | | | | | 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>
* | Use hash-based file names in ical_read_note()Lukas Fleischer2011-10-051-14/+9
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use hash-bashed file names in edit_note()Lukas Fleischer2011-10-051-11/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Accept variable length note namesLukas Fleischer2011-10-054-10/+22
| | | | | | | | | | | | | | | | 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>
* | Refactor out note deserializationLukas Fleischer2011-10-053-8/+12
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a copy file routineLukas Fleischer2011-10-052-0/+34
| | | | | | | | | | | | | | | | Add io_file_cp() which can be used to copy an existing source file to another location. We will need this for our new hash-based note file names. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a SHA1 implementationLukas Fleischer2011-10-053-0/+300
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an implementation of the SHA1 hash algorithm based on a public domain project by Steve Reid <sreid@sea-to-sky.net>. You can get the original sources from: ftp://ftp.funet.fi/pub/crypt/hash/sha/sha1.c We will need this for several things. File names of note files will be generated based on a hash their content instead of using a random name. Items can be uniquely identified using a hash. In addition to the regular sha1_init(), sha1_update() and sha1_final() operations, our implementation also contains wrappers for hashing a string or a stream. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-09-062-115/+78
|\| | | | | | | | | Conflicts: src/io.c
| * Rework indentation code in print_notefile()Lukas Fleischer2011-08-261-3/+9
| | | | | | | | | | | | | | Do not use snprintf() here as printf() behaviour is undefined if the destination pointer is used as a parameter. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/io.c: iCal content line folding correctnessLukas Fleischer2011-08-261-112/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a rather invasive change that introduces correct line folding to our iCal parser. From now on, ical_readline() should be used instead of fgets() to read lines from an iCal file as it unfolds lines automatically. We also need to use shared buffers as each ical_readline() invocation eats up the first part of the next line and stores it in the "lstore" buffer. Subsequent ical_readline() invocations copy the contents of this buffer and append continuation lines. We currently use a single buffer pair that is allocated in io_import_data() and pass it to all subroutines. ical_readline_init() needs to be called once for every buffer pair. It reads the first part of the current line and writes to "lstore", clearing the target buffer at the same time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add configuration option to notify all appointmentsLukas Fleischer2011-07-314-5/+31
| | | | | | | | | | | | | | | | If "notify-all" is enabled, all non-flagged appointments will be notified (instead of flagged ones). This is useful for users that want to be notified of everything. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-07-306-71/+115
|\|
| * Fix sort order in app_arg()Lukas Fleischer2011-07-301-52/+78
| | | | | | | | | | | | | | | | | | | | | | | | We used to iterate over the list of regular appointments and the list of recurrent appointments in separate loops, thus leading to recurrent appointments being printed first and regular appointments being printed afterwards, regardless of their start and end times. Merge these loops to coerce precedence of the start time. There's still a fair bit of hackery in here - we will fix that later. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Fix apoint_get() call in apoint_switch_notify()Lukas Fleischer2011-07-291-1/+1
| | | | | | | | | | | | | | We passed the function arguments the wrong way round. This regression was introduced in commit 77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Fix notify_check_repeated()Lukas Fleischer2011-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | Remove the "current_time" check from the first if condition. As "greater than" relations (">") have higher precedence than assignments ("=") in C, this caused "real_app_time" to always be one or zero which definitely isn't what we want here. Reading further down, it turns out that we don't even need this comparison here, so we should be fine removing it. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Fix recurrent appointment notificationLukas Fleischer2011-07-291-6/+3
| | | | | | | | | | | | We probably broke this in 9fab24818a119aef08b9726f6c1cd31d5434ce34. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Update the notification item in *_paste_item()Lukas Fleischer2011-07-292-0/+8
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Update the notification item in day_edit_item()Lukas Fleischer2011-07-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | Ensure the start time as well as the description of the notification appointment are synced after editing it. We use notify_check_next_app()'s force parameter to ensure that the notification item is updated even if only the description was modified. Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Add "force" parameter to notify_check_next_app()Lukas Fleischer2011-07-294-11/+13
| | | | | | | | | | | | | | | | This allows to force notify_check_next_app() to update the notification appointment, even if start times are equal (e.g. if the item description was changed). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Fix configuration file backward compatibilityLukas Fleischer2011-07-291-2/+7
| | | | | | | | | | | | | | | | We kinda broke this in 6377582841118688aee13aff98c9216403582e45. All hail strsep()! Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calcurse.h: Whitespace cleanupLukas Fleischer2011-07-281-73/+70
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/args.c: Mark various constant strings constLukas Fleischer2011-07-281-4/+4
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove superfluous buffer variable from version_arg()Lukas Fleischer2011-07-281-4/+1
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove superfluous buffer variable from help_arg()Lukas Fleischer2011-07-281-4/+1
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-07-282-2/+4
|\|
| * io.c: Accept resource parameters in iCal importLukas Fleischer2011-07-281-2/+2
| | | | | | | | | | | | | | | | | | Remove colons from the "SUMMARY:" and "DURATION:" search patterns in ical_read_event() to allow for additional parameters (such as language parameters, cf. RFC 5545). Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Invoke vars_init() before importing data with "-i"Lukas Fleischer2011-07-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We forgot to call vars_init() when importing an item using the "-i" command line argument, which led to the pager configuration variable being unset and hence the pager invocation (triggered to show the log in case there are any errors during import) failing. Fix this by calling vars_init() before io_import_data(). Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use gettext plural featuresLukas Fleischer2011-07-242-8/+11
| | | | | | | | | | | | | | | | Make use of the plural features of gettext to handle plural forms correctly instead of using the plural form even if the singular form should be used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Split stats messages in io_import_data()Lukas Fleischer2011-07-241-10/+12
| | | | | | | | | | | | | | | | Use separate format strings for separate values. This is useful in case we want to output similar stats somewhere else and is a preparation for supporting plural forms. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out note functionsLukas Fleischer2011-07-216-66/+103
| | | | | | | | | | | | | | | | | | | | * 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>
* | Add hint to error messages in custom_load_conf()Lukas Fleischer2011-07-211-2/+2
| | | | | | | | | | | | | | | | Include the name of the configuration variable that issued the error in error messages that are thrown while parsing the configuration file. This makes it a lot easier to locate syntactic and semantic errors. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use map for configuration variable namesLukas Fleischer2011-07-211-49/+61
| | | | | | | | | | | | | | | | | | Use a map instead of dozens of hardcoded conditionals. This makes configuration variable parsing more dynamic and extensible. Also, reintroduce formatting error messages that we dropped earlier. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Return error status in custom_set_conf()Lukas Fleischer2011-07-211-14/+16
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Rename custom_load_color() to conf_parse_color()Lukas Fleischer2011-07-211-21/+16
| | | | | | | | | | | | | | Also, temporarily remove all error messages and return an error status instead. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Declare foreground and background variables globalLukas Fleischer2011-07-216-12/+15
| | | | | | | | | | | | Removes the need to pass the terminal's default background color round. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out integer variable parsingLukas Fleischer2011-07-211-6/+26
| | | | | | | | | | | | | | Introduce conf_parse_unsigned() and conf_parse_int() similar to conf_parse_bool(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor conf_parse_bool()Lukas Fleischer2011-07-212-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | * Increase size argument for strncmp() comparisons by one to include the terminating null-character (otherwise "yesfoo" would be parsed as "yes", "nobar" as "no"). * Pass destination address as an additional argument and return success/failure status to allow for better error handling. * Temporarily remove error handling (will be fixed later). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Rename fill_config_var() to conf_parse_bool()Lukas Fleischer2011-07-211-10/+10
| | | | | | | | | | | | | | This is a much better name as it implicitly describes that this function parses boolean configuration values only. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out configuration variable settingLukas Fleischer2011-07-211-75/+82
| | | | | | | | | | | | | | | | Move configuration variable assignments to a new function, custom_set_conf(). This improves code readability and allows for setting configuration variables outside the configuration file loading function. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use single-line configuration settings by defaultLukas Fleischer2011-07-151-22/+23
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Parse single-line configuration variablesLukas Fleischer2011-07-151-25/+33
| | | | | | | | | | | | | | Include a fallback branch that accepts multi-line comments as well (backward compatibility). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Be stricter when parsing the configuration fileLukas Fleischer2011-07-151-11/+6
| | | | | | | | | | | | | | | | Throw an error message if there is a line that contains an invalid configuration line (e.g. a non-empty line that neither contains a key nor a value). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Skip indentation and comments in io_extract_data()Lukas Fleischer2011-07-151-1/+2
| | | | | | | | | | | | | | | | We actually only use this function to parse configuration data. Currently, this probably is the best way to do some common preprocessing. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor custom_load_conf()Lukas Fleischer2011-07-151-63/+49
| | | | | | | | | | | | | | | | Read key and value of each configuration setting in one loop cycle to facilitate adjustments of the configuration setting format. Also, this allows us to get rid of all the redundant variable resetting. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Do not unnecessarily refresh in config menuLukas Fleischer2011-07-141-0/+2
| | | | | | | | | | | | | | We don't need to refresh windows every time an unassigned key is pressed. Add a condition to skip the refresh part if that is the case. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove artificial delay when saving dataLukas Fleischer2011-07-141-3/+0
| | | | | | | | | | | | | | | | This doesn't contribute to functionality or usability in any way. Keep the progress bar option but only show bars as long as the actual save operation is in progress. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-07-103-2/+20
|\|
| * Honor "TMPDIR" environment variableLukas Fleischer2011-07-093-2/+20
| | | | | | | | | | | | | | | | | | Replace all hardcoded paths referring to "/tmp" with a new function that honors the "TMPDIR" environment variable as well as P_tmpdir and uses "/tmp" as a fallback. Thanks-to: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>