summaryrefslogtreecommitdiffstats
path: root/src/io.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a couple of translatable stringsLukas Fleischer2013-05-141-3/+3
| | | | | | | | * Remove space before punctuation. * Use "TODO" instead of "ToDo". * Strip some formats to make sure lines are <=80 characters wide. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use tabs instead of spaces for indentationLukas Fleischer2013-04-141-939/+1000
| | | | | | | | | | | This completes our switch to the Linux kernel coding style. Note that we still use deeply nested constructs at some places which need to be fixed up later. Converted using the `Lindent` script from the Linux kernel code base, along with some manual fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix braces in if-else statementsLukas Fleischer2013-02-171-12/+17
| | | | | | | | | | From the Linux kernel coding guidelines: Do not unnecessarily use braces where a single statement will do. [...] This does not apply if one branch of a conditional statement is a single statement. Use braces in both branches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* todo.c: Split out UI-related functionsLukas Fleischer2013-02-141-2/+2
| | | | | | | * Move UI-related functions to "ui-todo.c". * Rename UI-related functions to ui_todo_*(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2013-02-041-1/+1
| | | | | | | Add 2013 to the copyright range for all source and documentation files. Reported-by: Frederic Culot <frederic@culot.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Properly skip spaces after exception listLukas Fleischer2013-02-011-2/+4
| | | | | | | Skip whitespace after obtaining the list of exceptions instead of skipping the next character unconditionally. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Display correct startup messagesLukas Fleischer2012-12-161-2/+2
| | | | | | | These messages have been swapped accidentally during refactoring. Regression introduced in 691f8a6015bafcf6ed4f99a3649d428fb7a8e915. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add hidden key handler windowLukas Fleischer2012-12-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | After BUG#6 had apparently been closed with the screen locks introduced in commit a80f8dcf2c6eb3b54658218bc081ee9694204dd5, some people still had problems with random characters appearing in the notification bar. This was obviously caused by wgetch() refreshing the screen if the status panel was changed. From wgetch(3): If the window is not a pad, and it has been moved or modified since the last call to wrefresh, wrefresh will be called before another character is read. Since the wgetch(3) isn't thread-safe, there were race conditions between the notification bar thread drawing to the notification bar and wgetch() updating the screen. Introduce a (hidden) window that handles all key presses and never gets changed in order to avoid this. Also, call wins_wrefresh() explicitly in status_mesg(), since we can no longer rely on wgetch() updating windows automatically. Fixes reopened BUG#6. Note that this is a hotfix -- FR#26 has been opened to ensure we fix this properly in the next major release. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix two enumeration types in function signaturesLukas Fleischer2012-12-061-1/+1
| | | | | | Spotted with clang and "-Wconversion". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_load_keys(): Skip legacy entryLukas Fleischer2012-12-051-0/+5
| | | | | | | This binding was used pre-3.1.0. Simply ignore it and avoid showing a needlessly complicated error message. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_check_*()/io_file_exist(): Fix signaturesLukas Fleischer2012-11-261-3/+3
| | | | | | | This was broken in commit 87fb8cfec0d8e8fc901746095458bd316314b6ee. Fix function signatures and update all invocations accordingly. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io.c: Several minor simplificationsLukas Fleischer2012-11-251-43/+31
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_load_*(): Add line numbers to error messagesLukas Fleischer2012-11-231-12/+26
| | | | | | | | Currently, error messages for (syntax) errors do not contain any line number information. Add the file name and line number to allow users for easily locating any errors in the corresponding data files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2012-11-231-25/+5
|\ | | | | | | | | | | Conflicts: src/day.c src/recur.c
| * Do not display a mark when files are auto-savedLukas Fleischer2012-11-231-22/+2
| | | | | | | | | | | | | | | | | | | | This is kind of useless since users are not able to react to an auto-save notification. It also causes all kinds of problems if the status bar is in a non-standard mode (message, prompt, ...) and is prone to race conditions if the status bar is updated by another thread at the same time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Replace localtime() with localtime_r()Lukas Fleischer2012-11-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the result of localtime() is stored in a statically allocated structure, data was overwritten when a context switch occurred during (or shortly after) the execution of localtime(), potentially resulting in critical data corruption. BUG#7 and BUG#8 are likely related. This patch converts all usages of localtime() with localtime_r(), which is thread-safe. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Reported-by: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use status_ask_choice() for the export dialogLukas Fleischer2012-11-181-23/+0
| | | | | | | | | | | | | | | | Remove the export bar and use a simple status_ask_choice() dialog instead. This reduces code complexity and replaces another unnecessary menu by the well-tested dialog feature that is used everywhere else. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Allow passing both "-D" and "-c"Lukas Fleischer2012-06-301-33/+37
|/ | | | | | | | | | This is particularly useful if one wants to use configuration and key bindings from a specific directory, while using an appointment file from somewhere else. "-c" has precedence over "-D". Also update the usage message, man page and documentation. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use mvwaddstr() instead of mvwprintw()Baptiste Jonglez2012-05-311-10/+10
| | | | | | | | | | | | | When we only want to display a string at a specific place of the screen, there's no need to use the more complex mvwprintw(), use mvwaddstr() instead. This should be slightly more efficient, and, above all, it prevents weird things to happen if our string contains a '%', being interpreted as an unwanted format string. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Switch to Linux kernel coding styleLukas Fleischer2012-05-211-864/+709
| | | | | | | | | | | | | | Convert our code base to adhere to Linux kernel coding style using Lindent, with the following exceptions: * Use spaces, instead of tabs, for indentation. * Use 2-character indentations (instead of 8 characters). Rationale: We currently have too much levels of indentation. Using 8-character tabs would make huge code parts unreadable. These need to be cleaned up before we can switch to 8 characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Factorize boolean user prompting.Baptiste Jonglez2012-05-141-10/+2
| | | | | | | | | | | Introduce a new `status_ask_bool()` function, and use it where applicable. This greatly reduces code duplication, and will allow handling special events (resize, user escape) much more uniformely. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Declare several parameters/variables constantLukas Fleischer2012-05-081-13/+14
| | | | | | | | | | | | Add the "const" keyword to parameters and variables that are never modified. Most of these were spotted by "-Wwrite-strings". We cast the second parameter to execvp() explicitly as it expects a "char *const[]" where it should expect a "const char *const[]" (according to the documentation, this is due to compatibility reasons). This should be changed once we come up with a better solution. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add prototypes for hash table functionsLukas Fleischer2012-04-211-0/+1
| | | | | | These can be generated dynamically using the HTABLE_PROTOTYPE macro. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark several functions staticLukas Fleischer2012-04-201-1/+1
| | | | | | | These are not needed outside of the corresponding compilation units. Spotted with "-Wmissing-prototypes". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Refactor startup screen branchLukas Fleischer2012-04-121-14/+8
| | | | | | | Removes the pointless first parameter to io_startup_screen() and saves one wins_update() call if system dialogs are disabled. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Miscellaneous small code cleanupsLukas Fleischer2012-04-061-3/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark some more variables/parameters constantLukas Fleischer2012-04-051-2/+2
| | | | | | Fixes a couple of warnings seen with GCC 4.7. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark localized string literals constantLukas Fleischer2012-04-051-22/+22
| | | | | | | Translated strings returned by gettext() are statically allocated and shouldn't be modified. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix semantics of "general."{systemdialogs,progressbar}Lukas Fleischer2012-03-291-6/+6
| | | | | | | | | These were renamed from "skip_"* to *. However, we only changed syntax and didn't invert their semantic meaning. Fix this by negating the semantics of those variables. Also, negate these in the configuration file automatically when running `calcurse-upgrade`. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2012-03-261-1/+1
| | | | | | Add 2012 to the copyright range for all source and documentation files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add a read-only optionLukas Fleischer2012-02-241-8/+24
| | | | | | | We don't save any configuration nor items if this is set. This should be used with care, and hence there's no short option for this. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/io.c: Remove C89 incompatible commentLukas Fleischer2012-02-201-1/+1
| | | | | | | Make commenting style consistent with everywhere else. Use "/* [...] */" instead of "// [...]". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix up fscanf() format stringsLukas Fleischer2012-02-191-3/+3
| | | | | | | All members of the tm structure are signed integers. Stick to using the correct fscanf() format specifiers for these. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix hash table issues with ISO C99Lukas Fleischer2012-02-191-7/+10
| | | | | | | | | | 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>
* Remove all usages of bzero() and bcopy()Lukas Fleischer2012-02-191-2/+2
| | | | | | | | | The bzero() and bcopy() functions are deprecated and were removed from the POSIX standard in IEEE Std. 1003.1-2008. Remove all usages of bzero()/bcopy() and replace them by appropriate memset()/memmove() calls. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/io.c: Use fork_exec() instead of system()Lukas Fleischer2012-02-181-3/+4
| | | | | | | Speeds up execution, prevents failures when pager or log file contains spaces, fixes a warning seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add stricter syntax checking to io_load_*()Lukas Fleischer2012-02-181-33/+41
| | | | | | | | | | Be more restrictive with what we allow in data files and bail out if a line doesn't conform to our specification, especially in regard to separators. This prevents unexpected behavior when a data file is edited manually. As a bonus, this fixes a whole pile of compiler warnings previously seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Break out different import/export formatsLukas Fleischer2012-01-071-1501/+8
| | | | | | | | | | | | | | | | | | | | | | Extract iCal and pcal import/export routines into separate files. This reduces complexity of the super huge "io.c" source file and makes it easier to follow changes that affect the iCal and pcal routines only (commits affecting both formats are very uncommon). Before: $ wc -l src/io.c 2938 src/io.c After: $ wc -l src/{io,ical,pcal}.c 1445 src/io.c 1263 src/ical.c 317 src/pcal.c 3025 total Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2011-12-161-1/+5
|\ | | | | | | | | Conflicts: src/io.c
| * Format "DURATION" field properly on ical exportJérôme Pinot2011-12-161-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Use days/hours/minutes/seconds instead of seconds in the DURATION field. It fixes interaction with other softwares like phpicalendar. Lukas: Remove use of dur-week. RFC 5545 states that you cannot use this in conjunction with dur-day. Also, fix formatting and use proper constants. Signed-off-by: Jerome Pinot <ngc891@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Extract config file handlers into a separate fileLukas Fleischer2011-12-091-142/+1
| | | | | | | | | | | | | | | | We used custom_load_conf() to load the configuration file and io_save_conf() to save configuration. Move these functions, including all helpers, to a central location. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-11-151-2/+5
|\|
| * src/io.c: Avoid use of memcpy()Lukas Fleischer2011-11-111-2/+4
| | | | | | | | | | | | | | | | Use strncpy() and a proper limit, which ensures we never read more characters than the buffer can hold. Also, ensure we always null-terminate strings here. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/io.c: Null-terminate the ical_readline() bufferLukas Fleischer2011-11-111-0/+1
| | | | | | | | | | | | | | Ensure we always return with a null-terminated buffer, even if we read more than BUFSIZ characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use a global configuration variableLukas Fleischer2011-11-141-28/+26
| | | | | | | | | | | | | | This is one of the few valid use cases for a global variable. No need to make it pseudo-local and pass it from one function to another. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-11-111-1/+7
|\| | | | | | | | | | | Conflicts: src/calcurse.h src/io.c
| * Cleanup joinable threads on terminationLukas Fleischer2011-10-041-1/+4
| | | | | | | | | | | | | | Always invoke pthread_join() when we blow up a thread via pthread_cancel() (avoid zombie threads). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/io.c: Update todo item count on iCal importLukas Fleischer2011-10-041-0/+3
| | | | | | | | | | | | | | Update the number of todo items when importing an iCal file to prevent some items from being inaccessible. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove parentheses from return statementsLukas Fleischer2011-11-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | No reason to use "return (x);" here. Refer to the GNU coding guidelines for details. Created using following semantic patch: @@ expression expr; @@ - return (expr); + return expr; Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Do not cast unused return values to voidLukas Fleischer2011-11-021-268/+262
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>