aboutsummaryrefslogtreecommitdiffstats
path: root/src/ical.c
Commit message (Collapse)AuthorAgeFilesLines
* Refactor function calls: recurrence parameters as a single argumentLars Henriksen2020-04-281-20/+26
| | | | | | | | | | | | | | | | | | | | | The recurrence parameters are type, frequency, until date and exception list (in RFC 5545 parlance FREQ, INTERVAL, UNTIL and EXDATE's). When these are passed in a function call, the argument list becomes long and not very readable. When support for extended recurrence rules is implemented, the number of recurrence parameters increases, and function signatures must be amended. Solution: The "struct rpt" is extended with the exception list; any future recurrence parameters are added here. A pointer to this structure replaces the recurrence parameters in function calls. Note: Each recurrent event and appoinment instance has (a pointer to) a "struct rpt" and in addition an exception list. The latter is retained to avoid the derived changes, and the exception list in the structure is initialized to an empty list when the recurrent instance is created. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Extend use of note file for iCal importLars Henriksen2020-04-281-61/+280
| | | | | | | | | | iCal import to an item note file is extended from DESCRIPTION to LOCATION, COMMENT and STATUS for both events and todos. Addresses GitHub issue #9. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Accept empty DESCRIPTION in ical importLars Henriksen2020-04-281-5/+0
| | | | | | | Adresses GitHub issue #274. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix formatting of DTSTART for recurrent eventsJerem-K2020-04-281-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix decoding of escaped characters in imported textLars Henriksen2020-03-221-11/+20
| | | | | | | | Stick strictly to RFC 5545, 3.3.11, Text, for SUMMARY and DESCRIPTION. Adresses Github issue #271. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix ical import loggingLars Henriksen2020-03-221-29/+59
| | | | | | | | | | | | | | | | | | | | | | | | The following issues have been fixed: Functions ical_read_event() and ical_read__todo() do not check the return value of functions which may fail, in which case an item is not skipped even though a problem may have been logged by the called function. Function ical_read_note() fails on empty DESCRIPTION, but does not log it. Function ical_read_exdate() may log a failure, but cannot fail itself. Function ical_read_summary() can fail, but not log a failure. Function ical_read_todo() do not skip a todo with an invalid priority. Additionally: A safety check has been added to ical_get_value(), and log messages resulting from failures have been made uniform. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Improve ical import loggingLars Henriksen2020-03-221-15/+22
| | | | | | | | | The log file is not deleted if items were skipped (adresses Github issue #269). The log file includes the import file name and time. The import line numbers have been corrected (and tests amended). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Escape necessary characters in SUMMARY on exportKelvin Jackson2020-03-221-5/+26
| | | | | | | Escape semicolons, commas, and backslashes when exporting a calendar item to iCal format. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2020-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use ICALDATETIMEFMT for EXDATEHenrik Grimler2019-04-131-2/+2
| | | | | | Some servers (Radicale) cannot handle YYYYMM. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix priority parsing in iCal importsdott2018-11-241-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* ical: use the VALUE parameter in DTSTARTQuentin Hibon2018-05-101-1/+1
| | | | | | | | | According to RFC5545 3.3 (Property Value Data Types): "If the value type of a property is one of the alternate valid types, then it MUST be explicitly specified with the "VALUE" parameter." Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix spelling of "frequency"Lars Henriksen2017-10-231-2/+2
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Do not read past NUL character in ical_get_value()Lukas Fleischer2017-02-081-2/+2
| | | | | | | Make sure we never read beyond the end of the buffer, even if the terminating quote of a quoted string is missing. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Gracefully parse iCal parameters with colonsLukas Fleischer2017-02-071-12/+24
| | | | | | | | | | | | According to RFC 5545, iCalendar content lines can have optional parameters, which can be quoted strings containing colons (":"). Make sure that such colons are not interpreted as delimiters marking the start of the value string. Also, add a test case that covers this corner case. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2017-01-121-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Support format strings when dumping imported itemsLukas Fleischer2016-02-111-47/+36
| | | | | | | | | | | | | | In commit 3eae7ce (Add --list-imported command line option, 2016-01-12), we added an option to print the hashes of imported items to stdout. Extend this command line option such that it dumps the items using the specified formatting strings. With the new behavior it is, for example, easier to check items for import errors. Also, rename the option from --list-imported to --dump-imported (it is not part of any official release yet so we do not need to care about backwards compatibility). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2016-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Support todo items with an undefined priorityLukas Fleischer2016-01-181-9/+4
| | | | | | | In addition to priorities 1-9, support todo items without any specific priority, internally represented by priority 0. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use a separate field for the completed statusLukas Fleischer2016-01-181-11/+7
| | | | | | | Add a new field that indicates whether a todo item is completed or not instead of encoding completed todo items by negative priorities. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Export item UIDs upon requestLukas Fleischer2016-01-151-16/+51
| | | | | | | Add a new --export-uid command line option that adds each item's hash to the UID property when exporting. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* ical: Handle items without an end date gracefullyLukas Fleischer2016-01-131-16/+17
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* ical: Refactor item date/time parserLukas Fleischer2016-01-131-10/+8
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Reimplement ical_unformat_line() using dynamic stringsLukas Fleischer2016-01-131-22/+10
| | | | | | | Use the new dynamic string utility functions instead of relying on a fixed-size buffer. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* ical: Export completed todo items properlyLukas Fleischer2016-01-131-3/+6
| | | | | | | Do not skip completed todo items when exporting to an iCal file. Instead, mark them as "STATUS:COMPLETED". Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* ical: Honor completed status of todo itemsLukas Fleischer2016-01-131-0/+5
| | | | | | | When importing todo items from an iCal file, mark completed items as completed. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add --list-imported command line optionLukas Fleischer2016-01-131-20/+54
| | | | | | | When this option is used together with -i/--import, the object identifiers of imported objects are printed to stdout. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* ical.c: Small refactoringLukas Fleischer2015-02-251-15/+10
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use time_t instead of long in several placesLukas Fleischer2015-02-241-18/+12
| | | | | | | Start converting some variables and return values to store times from long to time_t. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ical.c: Reduce nesting depthLukas Fleischer2015-02-241-318/+257
| | | | | | Refactor the iCal parser to reduce nesting depth. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Introduce starts_with() and starts_with_ci()Lukas Fleischer2015-02-241-84/+31
| | | | | | | | Create user-defined functions to check whether a string contains a certain prefix instead of messing around with strncmp() and strncasecmp(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add support for UTC times in iCal importsLukas Fleischer2015-02-231-8/+13
| | | | | | | | | | | | | | According to the iCal standard (4.3.12 Time): UTC time, or absolute time, is identified by a LATIN CAPITAL LETTER Z suffix character (US-ASCII decimal 90), the UTC designator, appended to the time value. Parse such time values properly when importing iCal files. Fixes GitHub issue #3. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2015-02-071-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Correctly parse all types of iCal durationsLukas Fleischer2014-08-181-5/+14
| | | | | | | | This was supposed to be fixed in 6ca2535 (ical.c: Simplify and fix ical_durtime2long(), 2014-07-28) but some cases were not covered. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Gracefully handle all day events in iCal importsLukas Fleischer2014-08-181-11/+24
| | | | | | | | | Do not create two events when importing an event that lasts an entire day. Reported-by: Jörn Tillmanns <tillmanns@tuxzone.org> Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Handle CRLF line endings in iCal filesLukas Fleischer2014-08-181-4/+12
| | | | | | | | RFC 2445 mentions that CRLF line endings may be used in iCal files. Handle them properly when importing. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ical.c: Parse multiple exception rules properlyLukas Fleischer2014-07-281-1/+1
| | | | | | | | There can be multiple EXDATE lines per event. Parse them correctly instead of making the last line overwrite the previous ones. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ical.c: Simplify and fix ical_durtime2long()Lukas Fleischer2014-07-281-20/+15
| | | | | | | | Correctly parse all types of durations. Before this change, durations without an hour or minute component were not parsed properly. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ical.c: Remove newlines from item summariesLukas Fleischer2014-07-081-6/+12
| | | | | | | | | | Newline characters are not allowed in calcurse item descriptions. Replace any newlines in iCal summary lines with spaces. Fixes GitHub issue #6. Reported-by: Jonathan McCrohan <jmccrohan@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use tabs instead of spaces for indentationLukas Fleischer2013-04-141-772/+880
| | | | | | | | | | | 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-17/+23
| | | | | | | | | | 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>
* Merge branch 'maint'Lukas Fleischer2013-02-041-1/+1
|\
| * 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>
* | Use strncasecmp() for case-insensitive comparisonLukas Fleischer2013-01-301-30/+22
|/ | | | | | | Instead of converting everything to upper case and then using strncmp(), use strncasecmp() which does case-insensitive comparison out of the box. 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>
* Use integers rather than floats everywhereLukas Fleischer2012-07-101-16/+15
| | | | | | | | | | | We don't need floating point precision if results are casted back to integer. Instead, rearrange operations and do the integer division after the multiplication. Version numbers are terminating decimals anyway and can be stored using two integers without losing any information. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Switch to Linux kernel coding styleLukas Fleischer2012-05-211-818/+653
| | | | | | | | | | | | | | 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>
* Declare several parameters/variables constantLukas Fleischer2012-05-081-1/+1
| | | | | | | | | | | | 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>
* 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>
* Revert a bunch of strncmp() conversionsLukas Fleischer2012-03-301-22/+22
| | | | | | | | | | | All strncmp() usages were replaced by (evidently) equivalent strcmp() invocations in commit 2c9499bf272e06a62902711c6c20621ef3f80e64. However, some of the strncmp() calls were perfectly justified and we actually broke iCal import and "C-"-style key bindings by converting them to strcmp(). Fix this by reverting all affected conversions. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>