diff options
Diffstat (limited to 'src')
271 files changed, 4292 insertions, 4729 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9337d091..4959b3ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + add_subdirectory(libical) add_subdirectory(libicalss) add_subdirectory(libicalvcal) diff --git a/src/Net-ICal-Libical/Makefile.PL b/src/Net-ICal-Libical/Makefile.PL index 59d8d53d..60f3bc70 100644 --- a/src/Net-ICal-Libical/Makefile.PL +++ b/src/Net-ICal-Libical/Makefile.PL @@ -1,4 +1,8 @@ #!/usr/bin/perl +# +# SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +# use ExtUtils::MakeMaker; WriteMakefile( diff --git a/src/Net-ICal-Libical/README b/src/Net-ICal-Libical/README.txt index f6be345e..f6be345e 100644 --- a/src/Net-ICal-Libical/README +++ b/src/Net-ICal-Libical/README.txt diff --git a/src/Net-ICal-Libical/lib/Net/ICal/Libical.pm b/src/Net-ICal-Libical/lib/Net/ICal/Libical.pm index 070d58be..f4779ca4 100644 --- a/src/Net-ICal-Libical/lib/Net/ICal/Libical.pm +++ b/src/Net-ICal-Libical/lib/Net/ICal/Libical.pm @@ -3,18 +3,12 @@ # FILE: Libical.pm # CREATOR: eric # -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== # This part of this file was automatically generated by SWIG diff --git a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm index 54d9e0ba..46838f02 100644 --- a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm +++ b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Component.pm @@ -3,18 +3,12 @@ # FILE: Component.pm # CREATOR: eric 1 Mar 01 # -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== package Net::ICal::Libical::Component; diff --git a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm index 93b1852c..6c3903fe 100644 --- a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm +++ b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Duration.pm @@ -2,18 +2,12 @@ # FILE: Duration.pm # CREATOR: eric # -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #============================================================================= =head1 NAME diff --git a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm index 49a83e66..696d577e 100644 --- a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm +++ b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Period.pm @@ -3,18 +3,12 @@ # FILE: Component.pm # CREATOR: eric # -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== =pod diff --git a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Property.pm b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Property.pm index 16c987a6..c2cab511 100644 --- a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Property.pm +++ b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Property.pm @@ -3,18 +3,12 @@ # FILE: Property.pm # CREATOR: eric 1 Mar 01 # -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== use Net::ICal::Libical::Property; diff --git a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Time.pm b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Time.pm index 1afc8c40..5e744b2c 100644 --- a/src/Net-ICal-Libical/lib/Net/ICal/Libical/Time.pm +++ b/src/Net-ICal-Libical/lib/Net/ICal/Libical/Time.pm @@ -3,18 +3,12 @@ # FILE: Time.pm # CREATOR: eric # -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== =pod diff --git a/src/Net-ICal-Libical/netical.i b/src/Net-ICal-Libical/netical.i index 286de3c7..b97e25bc 100644 --- a/src/Net-ICal-Libical/netical.i +++ b/src/Net-ICal-Libical/netical.i @@ -1,18 +1,9 @@ /*====================================================================== FILE: ical.i - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom diff --git a/src/Net-ICal-Libical/test/component.pl b/src/Net-ICal-Libical/test/component.pl index f3e9c915..a55a4a73 100644 --- a/src/Net-ICal-Libical/test/component.pl +++ b/src/Net-ICal-Libical/test/component.pl @@ -1,17 +1,11 @@ #!/usr/bin/perl #====================================================================== -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== use lib "../blib/lib"; diff --git a/src/Net-ICal-Libical/test/libical.pl b/src/Net-ICal-Libical/test/libical.pl index 74586c48..4624943e 100755..100644 --- a/src/Net-ICal-Libical/test/libical.pl +++ b/src/Net-ICal-Libical/test/libical.pl @@ -1,17 +1,11 @@ #!/usr/bin/perl #====================================================================== -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== use lib "../blib/lib"; diff --git a/src/Net-ICal-Libical/test/swig.pl b/src/Net-ICal-Libical/test/swig.pl index de6c1792..df3dc316 100755..100644 --- a/src/Net-ICal-Libical/test/swig.pl +++ b/src/Net-ICal-Libical/test/swig.pl @@ -1,17 +1,11 @@ #!/usr/bin/perl #====================================================================== -# (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== use lib "../blib/lib"; diff --git a/src/java/CMakeLists.txt b/src/java/CMakeLists.txt index 0b9c08a4..d1dd43d9 100644 --- a/src/java/CMakeLists.txt +++ b/src/java/CMakeLists.txt @@ -1,3 +1,5 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ########### next target ############### diff --git a/src/java/ICalDurationType.java b/src/java/ICalDurationType.java index 2dcc2344..045589d9 100644 --- a/src/java/ICalDurationType.java +++ b/src/java/ICalDurationType.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: ICalDurationType.java CREATOR: structConverter 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; diff --git a/src/java/ICalParameter.java b/src/java/ICalParameter.java index af764e27..078c05f8 100644 --- a/src/java/ICalParameter.java +++ b/src/java/ICalParameter.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: ICalParameter.java CREATOR: gnorman 01/09/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; diff --git a/src/java/ICalPeriodType.java b/src/java/ICalPeriodType.java index 204ff2a1..765ca0c1 100644 --- a/src/java/ICalPeriodType.java +++ b/src/java/ICalPeriodType.java @@ -1,6 +1,8 @@ /*====================================================================== FILE: ICalPeriodType.java CREATOR: structConverter 01/11/02 + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -68,4 +70,3 @@ public class ICalPeriodType private ICalTimeType end = new ICalTimeType(); private ICalDurationType duration = new ICalDurationType(); } - diff --git a/src/java/ICalProperty.java b/src/java/ICalProperty.java index 87e99f6e..a93b4e0a 100644 --- a/src/java/ICalProperty.java +++ b/src/java/ICalProperty.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: ICalProperty.java CREATOR: gnorman 01/09/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; diff --git a/src/java/ICalRecurrenceType.java b/src/java/ICalRecurrenceType.java index cfe27911..e53bf93d 100644 --- a/src/java/ICalRecurrenceType.java +++ b/src/java/ICalRecurrenceType.java @@ -1,6 +1,8 @@ /*====================================================================== FILE: ICalRecurrenceType.java CREATOR: structConverter 01/11/02 + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -281,4 +283,3 @@ public class ICalRecurrenceType public static final int ICAL_BY_MONTH_SIZE = 13; public static final int ICAL_BY_SETPOS_SIZE = 367; } - diff --git a/src/java/ICalTimeType.java b/src/java/ICalTimeType.java index 15cf8715..ad0946c9 100644 --- a/src/java/ICalTimeType.java +++ b/src/java/ICalTimeType.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: ICalTimeType.java CREATOR: structConverter 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -132,4 +133,3 @@ public class ICalTimeType private int is_date; private String zone = new String(); // Converted from char* } - diff --git a/src/java/ICalTriggerType.java b/src/java/ICalTriggerType.java index e2ef7a72..d23f3ba4 100644 --- a/src/java/ICalTriggerType.java +++ b/src/java/ICalTriggerType.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: ICalTriggerType.java CREATOR: structConverter 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -90,4 +91,3 @@ public class ICalTriggerType private ICalTimeType time = new ICalTimeType(); private ICalDurationType duration = new ICalDurationType(); } - diff --git a/src/java/ICalValue.java b/src/java/ICalValue.java index f7160ff6..94c7de99 100644 --- a/src/java/ICalValue.java +++ b/src/java/ICalValue.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: ICalValue.java CREATOR: gnorman 01/10/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; diff --git a/src/java/VAgenda.java b/src/java/VAgenda.java index 8b85fe11..d487c0eb 100644 --- a/src/java/VAgenda.java +++ b/src/java/VAgenda.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VAgenda.java CREATOR: fnguyen 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -10,7 +11,7 @@ public class VAgenda extends VComponent { public VAgenda() { super(ICalComponentKind.ICAL_VAGENDA_COMPONENT); - } + } public VAgenda(long obj) { diff --git a/src/java/VAlarm.java b/src/java/VAlarm.java index d7693f76..2de52e89 100644 --- a/src/java/VAlarm.java +++ b/src/java/VAlarm.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VAlarm.java CREATOR: fnguyen 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -11,7 +12,7 @@ public class VAlarm extends VComponent { { super(ICalComponentKind.ICAL_VALARM_COMPONENT); } - + public VAlarm(long obj) { super(obj); diff --git a/src/java/VCalendar.java b/src/java/VCalendar.java index 4cfcad27..a3f0958f 100644 --- a/src/java/VCalendar.java +++ b/src/java/VCalendar.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VCalendar.java CREATOR: echoi 01/28/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -10,7 +11,7 @@ public class VCalendar extends VComponent { public VCalendar() { super(ICalComponentKind.ICAL_VCALENDAR_COMPONENT); - } + } public VCalendar(long obj) { diff --git a/src/java/VComponent.java b/src/java/VComponent.java index d77c5bb9..b828b32c 100644 --- a/src/java/VComponent.java +++ b/src/java/VComponent.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VComponent.java CREATOR: gnorman 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; diff --git a/src/java/VEvent.java b/src/java/VEvent.java index 2017aa58..33019b81 100644 --- a/src/java/VEvent.java +++ b/src/java/VEvent.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VEvent.java CREATOR: fnguyen 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -10,7 +11,7 @@ public class VEvent extends VComponent { public VEvent() { super(ICalComponentKind.ICAL_VEVENT_COMPONENT); - } + } public VEvent(long obj) { diff --git a/src/java/VFreeBusy.java b/src/java/VFreeBusy.java index a781edc5..c8dbf144 100644 --- a/src/java/VFreeBusy.java +++ b/src/java/VFreeBusy.java @@ -1,10 +1,17 @@ +/*====================================================================== + FILE: VFreeBusy.java + CREATOR: + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +======================================================================*/ + package net.cp.jlibical; public class VFreeBusy extends VComponent { public VFreeBusy() { super(ICalComponentKind.ICAL_VFREEBUSY_COMPONENT); - } + } public VFreeBusy(long obj) { diff --git a/src/java/VQuery.java b/src/java/VQuery.java index e94a0732..d827534a 100644 --- a/src/java/VQuery.java +++ b/src/java/VQuery.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VQuery.java CREATOR: fnguyen 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -10,7 +11,7 @@ public class VQuery extends VComponent { public VQuery() { super(ICalComponentKind.ICAL_VQUERY_COMPONENT); - } + } public VQuery(long obj) { diff --git a/src/java/VToDo.java b/src/java/VToDo.java index 9e4a06e1..af1e2bcf 100644 --- a/src/java/VToDo.java +++ b/src/java/VToDo.java @@ -1,7 +1,8 @@ /*====================================================================== FILE: VToDo.java CREATOR: fnguyen 01/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ package net.cp.jlibical; @@ -10,7 +11,7 @@ public class VToDo extends VComponent { public VToDo() { super(ICalComponentKind.ICAL_VTODO_COMPONENT); - } + } public VToDo(long obj) { diff --git a/src/java/jlibical_consts_cxx.h b/src/java/jlibical_consts_cxx.h index b4c72da4..d970b660 100644 --- a/src/java/jlibical_consts_cxx.h +++ b/src/java/jlibical_consts_cxx.h @@ -2,18 +2,10 @@ FILE: jlibical_consts_cxx/h CREATOR: Srinivasa Boppana/George Norman - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef JLIBICAL_CONSTS_CXX_H #define JLIBICAL_CONSTS_CXX_H diff --git a/src/java/jlibical_utils_cxx.cpp b/src/java/jlibical_utils_cxx.cpp index d89ee862..e52e33f4 100644 --- a/src/java/jlibical_utils_cxx.cpp +++ b/src/java/jlibical_utils_cxx.cpp @@ -2,18 +2,10 @@ FILE: jlibical_utils_cxx.cpp CREATOR: Srinivasa Boppana/George Norman - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef JLIBICAL_UTILS_CXX_H @@ -415,7 +407,6 @@ jobject doCreateNewSurrogate(JNIEnv *env, jclass surrogateClass, jlong subject) return(result); } - //------------------------------------------------------- // For the given cpErr, create a new Exception and send it to env. // Note: Throw does not throw anything. It only sets the state. diff --git a/src/java/jlibical_utils_cxx.h b/src/java/jlibical_utils_cxx.h index d812202c..2a61b54e 100644 --- a/src/java/jlibical_utils_cxx.h +++ b/src/java/jlibical_utils_cxx.h @@ -2,18 +2,10 @@ FILE: jlibical_utils_cxx.h CREATOR: Srinivasa Boppana/George Norman - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef TEST_CXX_H @@ -66,5 +58,4 @@ jobject createNewICalPeriodType(JNIEnv *env, icalperiodtype* source); jobject doCreateNewSurrogate(JNIEnv *env, jclass surrogateClass, jlong subject); - #endif /*TEST_CXX_H*/ diff --git a/src/java/jniICalDurationType_cxx.cpp b/src/java/jniICalDurationType_cxx.cpp index d7bb9d97..de77ce94 100644 --- a/src/java/jniICalDurationType_cxx.cpp +++ b/src/java/jniICalDurationType_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: jniICalDurationType_cxx.cpp CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #include <jni.h> @@ -26,7 +18,6 @@ static jfieldID ICalDurationType_Hours_FID; static jfieldID ICalDurationType_Minutes_FID; static jfieldID ICalDurationType_Seconds_FID; - void initICalDurationTypeFieldIDs(JNIEnv* env, jclass clazz) { ICalDurationType_Is_neg_FID = env->GetFieldID(clazz, "is_neg", "I"); diff --git a/src/java/jniICalDurationType_cxx.h b/src/java/jniICalDurationType_cxx.h index a7408e3c..44b28db7 100644 --- a/src/java/jniICalDurationType_cxx.h +++ b/src/java/jniICalDurationType_cxx.h @@ -2,18 +2,10 @@ FILE: jniICalDurationType_cxx.h CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _jni_ICalDurationType_H #define _jni_ICalDurationType_H @@ -22,7 +14,6 @@ // I forgot how to do this using a typedef in c++!!!! #define ICalDurationType icaldurationtype - #ifdef __cplusplus extern "C" { #endif @@ -49,7 +40,6 @@ void jni_GetAll_from_ICalDurationType(struct ICalDurationType* __ICalDurationTyp JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalDurationType_initFIDs(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalDurationType_init__J(JNIEnv *env, jobject thisICalDurationType, jlong data); - #ifdef __cplusplus } #endif diff --git a/src/java/jniICalPeriodType_cxx.cpp b/src/java/jniICalPeriodType_cxx.cpp index 84d3ed61..d1df8cdb 100644 --- a/src/java/jniICalPeriodType_cxx.cpp +++ b/src/java/jniICalPeriodType_cxx.cpp @@ -2,19 +2,11 @@ FILE: jniICalPeriodType_cxx.cpp CREATOR: structConverter - (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> - (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> + SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #include <jni.h> @@ -26,7 +18,6 @@ static jfieldID ICalPeriodType_Start_FID; static jfieldID ICalPeriodType_End_FID; static jfieldID ICalPeriodType_Duration_FID; - void initICalPeriodTypeFieldIDs(JNIEnv* env, jclass clazz) { ICalPeriodType_Start_FID = env->GetFieldID(clazz, "start", "Lnet/cp/jlibical/ICalTimeType;"); diff --git a/src/java/jniICalPeriodType_cxx.h b/src/java/jniICalPeriodType_cxx.h index 5928219c..62d8a2e9 100644 --- a/src/java/jniICalPeriodType_cxx.h +++ b/src/java/jniICalPeriodType_cxx.h @@ -2,18 +2,10 @@ FILE: jniICalPeriodType_cxx.h CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _jni_ICalPeriodType_H #define _jni_ICalPeriodType_H @@ -22,7 +14,6 @@ // I forgot how to do this using a typedef in c++!!!! #define ICalPeriodType icalperiodtype - #ifdef __cplusplus extern "C" { #endif @@ -44,7 +35,6 @@ void jni_GetAll_from_ICalPeriodType(struct ICalPeriodType* __ICalPeriodType_, JN JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalPeriodType_init__J(JNIEnv* env, jobject thisICalPeriodType, jlong data); JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalPeriodType_initFIDs(JNIEnv *env, jclass clazz); - #ifdef __cplusplus } #endif diff --git a/src/java/jniICalRecurrenceType_cxx.cpp b/src/java/jniICalRecurrenceType_cxx.cpp index 34048eaa..83325894 100644 --- a/src/java/jniICalRecurrenceType_cxx.cpp +++ b/src/java/jniICalRecurrenceType_cxx.cpp @@ -1,17 +1,8 @@ /*====================================================================== FILE: jniICalRecurrenceType_cxx.cpp CREATOR: structConverter - - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ #include <jni.h> @@ -35,7 +26,6 @@ static jfieldID ICalRecurrenceType_By_week_no_FID; static jfieldID ICalRecurrenceType_By_month_FID; static jfieldID ICalRecurrenceType_By_set_pos_FID; - void initICalRecurrenceTypeFieldIDs(JNIEnv* env, jclass clazz) { ICalRecurrenceType_Until_FID = env->GetFieldID(clazz, "until", "Lnet/cp/jlibical/ICalTimeType;"); @@ -343,7 +333,6 @@ void jni_GetAll_from_ICalRecurrenceType(struct ICalRecurrenceType* __ICalRecurre jni_GetBy_week_no_from_ICalRecurrenceType(__ICalRecurrenceType_, env, thisICalRecurrenceType); jni_GetBy_month_from_ICalRecurrenceType(__ICalRecurrenceType_, env, thisICalRecurrenceType); jni_GetBy_set_pos_from_ICalRecurrenceType(__ICalRecurrenceType_, env, thisICalRecurrenceType); - } JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalRecurrenceType_init__J(JNIEnv* env, jobject thisICalRecurrenceType, jlong data) { diff --git a/src/java/jniICalRecurrenceType_cxx.h b/src/java/jniICalRecurrenceType_cxx.h index 683cc017..47d90d1b 100644 --- a/src/java/jniICalRecurrenceType_cxx.h +++ b/src/java/jniICalRecurrenceType_cxx.h @@ -2,18 +2,10 @@ FILE: jniICalRecurrenceType_cxx.h CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _jni_ICalRecurrenceType_H_ #define _jni_ICalRecurrenceType_H_ @@ -63,7 +55,6 @@ void jni_GetAll_from_ICalRecurrenceType(struct ICalRecurrenceType* __ICalRecurre JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalRecurrenceType_init__J(JNIEnv* env, jobject thisICalRecurrenceType, jlong data); JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalRecurrenceType_initFIDs(JNIEnv *env, jclass clazz); - #ifdef __cplusplus } #endif diff --git a/src/java/jniICalTimeType_cxx.cpp b/src/java/jniICalTimeType_cxx.cpp index 9609b3b8..f956a7f3 100644 --- a/src/java/jniICalTimeType_cxx.cpp +++ b/src/java/jniICalTimeType_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: jniICalTimeType_cxx.cpp CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #include <jni.h> @@ -30,7 +22,6 @@ static jfieldID ICalTimeType_Second_FID; static jfieldID ICalTimeType_Is_date_FID; static jfieldID ICalTimeType_Zone_FID; - void initICalTimeTypeFieldIDs(JNIEnv* env, jclass clazz) { ICalTimeType_Year_FID = env->GetFieldID(clazz, "year", "I"); diff --git a/src/java/jniICalTimeType_cxx.h b/src/java/jniICalTimeType_cxx.h index ac28303d..e0f6fb9e 100644 --- a/src/java/jniICalTimeType_cxx.h +++ b/src/java/jniICalTimeType_cxx.h @@ -2,18 +2,10 @@ FILE: jniICalTimeType_cxx.h CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _jni_ICalTimeType_H #define _jni_ICalTimeType_H @@ -52,7 +44,6 @@ void jni_GetAll_from_ICalTimeType(struct ICalTimeType* __ICalTimeType_, JNIEnv* JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalTimeType_initFIDs(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalTimeType_init__J(JNIEnv* env, jobject thisICalTimeType, jlong data); - #ifdef __cplusplus } #endif diff --git a/src/java/jniICalTriggerType_cxx.cpp b/src/java/jniICalTriggerType_cxx.cpp index 42cea1aa..fd1a93a4 100644 --- a/src/java/jniICalTriggerType_cxx.cpp +++ b/src/java/jniICalTriggerType_cxx.cpp @@ -2,18 +2,10 @@ FILE: jniICalTriggerType_cxx.cpp CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #include <jni.h> @@ -24,7 +16,6 @@ static jfieldID ICalTriggerType_Time_FID; static jfieldID ICalTriggerType_Duration_FID; - void initICalTriggerTypeFieldIDs(JNIEnv* env, jclass clazz) { ICalTriggerType_Time_FID = env->GetFieldID(clazz, "time", "Lnet/cp/jlibical/ICalTimeType;"); diff --git a/src/java/jniICalTriggerType_cxx.h b/src/java/jniICalTriggerType_cxx.h index 3835caf5..e71f8f25 100644 --- a/src/java/jniICalTriggerType_cxx.h +++ b/src/java/jniICalTriggerType_cxx.h @@ -2,18 +2,10 @@ FILE: jniICalTriggerType_cxx.h CREATOR: structConverter - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _jni_ICalTriggerType_H @@ -23,7 +15,6 @@ // I forgot how to do this using a typedef in c++!!!! #define ICalTriggerType icaltriggertype - #ifdef __cplusplus extern "C" { #endif @@ -42,7 +33,6 @@ void jni_GetAll_from_ICalTriggerType(struct ICalTriggerType* __ICalTriggerType_, JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalTriggerType_init__J(JNIEnv* env, jobject thisICalTriggerType, jlong data); JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalTriggerType_initFIDs(JNIEnv *env, jclass clazz); - #ifdef __cplusplus } #endif diff --git a/src/java/net_cp_jlibical_ICalParameter_cxx.cpp b/src/java/net_cp_jlibical_ICalParameter_cxx.cpp index d3d52da6..b55807a8 100644 --- a/src/java/net_cp_jlibical_ICalParameter_cxx.cpp +++ b/src/java/net_cp_jlibical_ICalParameter_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: net_cp_jlibical_ICalParameter_cxx.cpp CREATOR: gnorman 1/10/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef NET_CP_JLIBICAL_ICALPARAMETER_CXX_H diff --git a/src/java/net_cp_jlibical_ICalParameter_cxx.h b/src/java/net_cp_jlibical_ICalParameter_cxx.h index 1949a0f2..88ba98a6 100644 --- a/src/java/net_cp_jlibical_ICalParameter_cxx.h +++ b/src/java/net_cp_jlibical_ICalParameter_cxx.h @@ -2,18 +2,10 @@ FILE: net_cp_jlibical_ICalParameter_cxx.h CREATOR: javah 1/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _Included_net_cp_jlibical_ICalParameter #define _Included_net_cp_jlibical_ICalParameter diff --git a/src/java/net_cp_jlibical_ICalProperty_cxx.cpp b/src/java/net_cp_jlibical_ICalProperty_cxx.cpp index 415b696b..24846f15 100644 --- a/src/java/net_cp_jlibical_ICalProperty_cxx.cpp +++ b/src/java/net_cp_jlibical_ICalProperty_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: net_cp_jlibical_ICalProperty_cxx.cpp CREATOR: gnorman 1/10/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef NET_CP_JLIBICAL_ICALPROPERTY_CXX_H @@ -1388,7 +1380,6 @@ JNIEXPORT void JNICALL Java_net_cp_jlibical_ICalProperty_init__I setCObjectPtr(env,jobj,new ICalProperty((icalproperty_kind)kind)); } - /* * Class: net_cp_jlibical_ICalProperty * Method: set_status diff --git a/src/java/net_cp_jlibical_ICalProperty_cxx.h b/src/java/net_cp_jlibical_ICalProperty_cxx.h index b1c71c32..bc8af40f 100644 --- a/src/java/net_cp_jlibical_ICalProperty_cxx.h +++ b/src/java/net_cp_jlibical_ICalProperty_cxx.h @@ -2,18 +2,10 @@ FILE: net_cp_jlibical_ICalProperty_cxx.h CREATOR: javah 1/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _Included_net_cp_jlibical_ICalProperty #define _Included_net_cp_jlibical_ICalProperty diff --git a/src/java/net_cp_jlibical_ICalValue_cxx.cpp b/src/java/net_cp_jlibical_ICalValue_cxx.cpp index f01a9338..3068ce47 100644 --- a/src/java/net_cp_jlibical_ICalValue_cxx.cpp +++ b/src/java/net_cp_jlibical_ICalValue_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: net_cp_jlibical_ICalValue_cxx.cpp CREATOR: gnorman 1/10/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef NET_CP_JLIBICAL_ICALVALUE_CXX_H diff --git a/src/java/net_cp_jlibical_ICalValue_cxx.h b/src/java/net_cp_jlibical_ICalValue_cxx.h index f7ffde37..7de5cadc 100644 --- a/src/java/net_cp_jlibical_ICalValue_cxx.h +++ b/src/java/net_cp_jlibical_ICalValue_cxx.h @@ -2,18 +2,10 @@ FILE: net_cp_jlibical_ICalValue_cxx.h CREATOR: javah 1/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _Included_net_cp_jlibical_ICalValue #define _Included_net_cp_jlibical_ICalValue diff --git a/src/java/net_cp_jlibical_VComponent_cxx.cpp b/src/java/net_cp_jlibical_VComponent_cxx.cpp index 1b5bb852..d7054618 100644 --- a/src/java/net_cp_jlibical_VComponent_cxx.cpp +++ b/src/java/net_cp_jlibical_VComponent_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: net_cp_jlibical_VComponent_cxx.cpp CREATOR: gnorman 1/10/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef NET_CP_JLIBICAL_VCOMPONENT_CXX_H @@ -470,7 +462,6 @@ JNIEXPORT jobject JNICALL Java_net_cp_jlibical_VComponent_get_1dtend // create a new surrogate, using aTime as the subject. result = createNewICalTimeType(env,&aTime); - } return(result); diff --git a/src/java/net_cp_jlibical_VComponent_cxx.h b/src/java/net_cp_jlibical_VComponent_cxx.h index 3bf9d09e..8aa703af 100644 --- a/src/java/net_cp_jlibical_VComponent_cxx.h +++ b/src/java/net_cp_jlibical_VComponent_cxx.h @@ -2,18 +2,10 @@ FILE: net_cp_jlibical_VComponent_cxx.h CREATOR: javah 1/11/02 - (C) COPYRIGHT 2002, Critical Path + SPDX-FileCopyrightText: 2002, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef _Included_net_cp_jlibical_VComponent #define _Included_net_cp_jlibical_VComponent diff --git a/src/java/testjni.java b/src/java/testjni.java index bb6a6aee..89ff875b 100644 --- a/src/java/testjni.java +++ b/src/java/testjni.java @@ -1,3 +1,10 @@ +/*====================================================================== + FILE: testjni.java + CREATOR: + SPDX-FileCopyrightText: 2002, Critical Path + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +======================================================================*/ + package net.cp.jlibical; import java.lang.String; diff --git a/src/libical-glib/CMakeLists.txt b/src/libical-glib/CMakeLists.txt index 096f9bb4..967b4b98 100644 --- a/src/libical-glib/CMakeLists.txt +++ b/src/libical-glib/CMakeLists.txt @@ -1,5 +1,12 @@ +# SPDX-FileCopyrightText: Milan Crha <mcrha@redhat.com> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + add_definitions(-Dlibical_ical_EXPORTS) +# a C11 compliant compiler is required to build this library +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) + # build ical-glib-src-generator add_executable(ical-glib-src-generator tools/generator.c @@ -85,9 +92,14 @@ else() endif() add_custom_command ( - OUTPUT ${LIBICAL_GLIB_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/libical-glib-private.h ${CMAKE_CURRENT_BINARY_DIR}/i-cal-forward-declarations.h - COMMAND ${ical-glib-src-generator_EXE} "${CMAKE_CURRENT_SOURCE_DIR}/tools" "${CMAKE_CURRENT_SOURCE_DIR}/api" + OUTPUT + ${LIBICAL_GLIB_SOURCES} + ${CMAKE_CURRENT_BINARY_DIR}/libical-glib-private.h + ${CMAKE_CURRENT_BINARY_DIR}/i-cal-forward-declarations.h + COMMAND + ${ical-glib-src-generator_EXE} "${CMAKE_CURRENT_SOURCE_DIR}/tools" "${CMAKE_CURRENT_SOURCE_DIR}/api" DEPENDS ${ical-glib-src-generator_EXE} ${xml_files} + COMMENT "Generate libical-glib headers" ) configure_file( @@ -121,10 +133,14 @@ add_dependencies(ical-glib ical-header) target_compile_options(ical-glib PRIVATE ${GLIB_CFLAGS}) target_compile_definitions(ical-glib PRIVATE -DG_LOG_DOMAIN="libical-glib" -DLIBICAL_GLIB_COMPILATION) target_link_libraries(ical-glib PRIVATE ical ${GLIB_LIBRARIES}) -if(NOT SHARED_ONLY) +if(NOT SHARED_ONLY AND NOT STATIC_ONLY) add_library(ical-glib-static STATIC ${LIBICAL_GLIB_SOURCES}) add_dependencies(ical-glib-static ical-header) - target_compile_options(ical-glib-static PUBLIC ${GLIB_CFLAGS} -DG_LOG_DOMAIN="libical-glib" -DLIBICAL_GLIB_COMPILATION) + target_compile_options(ical-glib-static + PUBLIC ${GLIB_CFLAGS} + -DG_LOG_DOMAIN="libical-glib" + -DLIBICAL_GLIB_COMPILATION + ) target_link_libraries(ical-glib-static ${GLIB_LIBRARIES}) endif() @@ -172,7 +188,14 @@ if(HAVE_INTROSPECTION) set(ICalGLib_${LIB_VERSION}_gir_VERSION ${LIBICAL_GLIB_GIR_VERSION_STRING}) set(ICalGLib_${LIB_VERSION}_gir_LIBRARY "ICalGLib") set(ICalGLib_${LIB_VERSION}_gir_INCLUDES GObject-2.0 GLib-2.0) - set(ICalGLib_${LIB_VERSION}_gir_CFLAGS ${_includes} ${GLIB_CFLAGS} -DLIBICAL_GLIB_COMPILATION -I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_BINARY_DIR}/src/libical -I${CMAKE_SOURCE_DIR}/src/libical -I${CMAKE_BINARY_DIR}/src/libical-glib) + set(ICalGLib_${LIB_VERSION}_gir_CFLAGS ${GLIB_CFLAGS} + -DLIBICAL_GLIB_COMPILATION + -I${CMAKE_CURRENT_BINARY_DIR} + -I${CMAKE_CURRENT_SOURCE_DIR} + -I${CMAKE_BINARY_DIR}/src/libical + -I${CMAKE_SOURCE_DIR}/src/libical + -I${CMAKE_BINARY_DIR}/src/libical-glib + ) set(ICalGLib_${LIB_VERSION}_gir_LIBS ical-glib) set(ICalGLib_${LIB_VERSION}_gir_FILES ${LIBICAL_GLIB_GIR_SOURCES}) @@ -182,7 +205,7 @@ if(HAVE_INTROSPECTION) endif() if(ICAL_GLIB_VAPI) - add_custom_target(vala ALL) + add_custom_target(vala ALL COMMENT "Target to run vala") set(gir_fullname ${CMAKE_BINARY_DIR}/src/libical-glib/ICalGLib-${LIBICAL_GLIB_GIR_VERSION_STRING}.gir) set(metadata_fullname ${CMAKE_CURRENT_BINARY_DIR}/ICalGLib-${LIBICAL_GLIB_GIR_VERSION_STRING}.metadata) set(vapi_file ${CMAKE_CURRENT_BINARY_DIR}/libical-glib.vapi) @@ -206,9 +229,10 @@ if(ICAL_GLIB_VAPI) DEPENDS ${gir_fullname} ${metadata_fullname} + COMMENT "Run the tool to generate the Vala API" ) - add_custom_target(valafile DEPENDS ${vapi_file}) + add_custom_target(valafile DEPENDS ${vapi_file} COMMENT "Target to run valafile") add_dependencies(vala valafile) @@ -217,11 +241,11 @@ endif() if(MSVC) set_target_properties(ical-glib PROPERTIES PREFIX "lib") - if(NOT SHARED_ONLY) + if(NOT SHARED_ONLY AND NOT STATIC_ONLY) set_target_properties(ical-glib-static PROPERTIES PREFIX "lib") endif() else() - if(NOT SHARED_ONLY) + if(NOT SHARED_ONLY AND NOT STATIC_ONLY) set_target_properties(ical-glib-static PROPERTIES OUTPUT_NAME "ical-glib") endif() endif() @@ -230,7 +254,7 @@ set_target_properties(ical-glib PROPERTIES SOVERSION ${LIBICAL_LIB_MAJOR_VERSION} ) set_target_properties(ical-glib PROPERTIES CLEAN_DIRECT_OUTPUT 1) -if(NOT SHARED_ONLY) +if(NOT SHARED_ONLY AND NOT STATIC_ONLY) set_target_properties(ical-glib-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) endif() @@ -239,7 +263,7 @@ install( EXPORT icalTargets DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS} ) -if(NOT SHARED_ONLY) +if(NOT SHARED_ONLY AND NOT STATIC_ONLY) install( TARGETS ical-glib-static EXPORT icalTargets @@ -257,8 +281,16 @@ install(FILES ${LIBICAL_GLIB_HEADERS} set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\${prefix}") -set(libdir "\${exec_prefix}/lib") -set(includedir "\${prefix}/include") +if(IS_ABSOLUTE ${LIB_INSTALL_DIR}) + set(libdir "${LIB_INSTALL_DIR}") +else() + set(libdir "\${exec_prefix}/${LIB_INSTALL_DIR}") +endif() +if(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR}) + set(includedir "${INCLUDE_INSTALL_DIR}") +else() + set(includedir "\${prefix}/include") +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/libical-glib.pc.in diff --git a/src/libical-glib/api/i-cal-array.xml b/src/libical-glib/api/i-cal-array.xml index 48edff92..5e8f4ba6 100644 --- a/src/libical-glib/api/i-cal-array.xml +++ b/src/libical-glib/api/i-cal-array.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Array" native="icalarray" is_possible_global="true" destroy_func="icalarray_free"> <method name="i_cal_array_size" corresponds="CUSTOM" kind="other" since="1.0"> @@ -54,7 +46,7 @@ <method name="i_cal_array_element_at" corresponds="icalarray_element_at" annotation="skip" kind="private" since="1.0"> <parameter type="ICalArray *" name="array" comment="The #ICalArray to be queried"/> <parameter type="gint" name="position" comment="The position the target element is located"/> - <returns type="GObject *" annotation="transfer none, allow-none" comment="The element located at the @position in the @array"/> + <returns type="GObject *" annotation="transfer none, nullable" comment="The element located at the @position in the @array"/> <comment xml:space="preserve">Gets the element located in the @position in the @array. NULL if position if out of bound.</comment> </method> <method name="i_cal_array_sort" corresponds="CUSTOM" annotation="skip" kind="others" since="1.0"> diff --git a/src/libical-glib/api/i-cal-attach.xml b/src/libical-glib/api/i-cal-attach.xml index 8d3582d8..970a02cb 100644 --- a/src/libical-glib/api/i-cal-attach.xml +++ b/src/libical-glib/api/i-cal-attach.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Attach" native="icalattach" destroy_func="icalattach_unref" new_full_extra_code="if (owner) { icalattach_ref (native); owner = NULL; }"> <method name="i_cal_attach_new_from_url" corresponds="icalattach_new_from_url" kind="constructor" since="1.0"> @@ -21,8 +13,8 @@ </method> <method name="i_cal_attach_new_from_data" corresponds="CUSTOM" kind="constructor" since="1.0"> <parameter type="const gchar *" name="data" comment="The data used to create the #ICalAttach"/> - <parameter type="GFunc" name="free_fn" translator="(icalattach_free_fn_t)" annotation="scope call, allow-none" comment="The function used to free the data when the create #ICalAttach is destroyed"/> - <parameter type="void *" name="free_fn_data" annotation="allow-none" comment="The userdata used for the free function @free_fn"/> + <parameter type="GFunc" name="free_fn" translator="(icalattach_free_fn_t)" annotation="scope call, nullable" comment="The function used to free the data when the create #ICalAttach is destroyed"/> + <parameter type="void *" name="free_fn_data" annotation="nullable" comment="The userdata used for the free function @free_fn"/> <returns type="ICalAttach *" annotation="transfer full" comment="The newly created #ICalAttach" /> <comment xml:space="preserve">Creates a new #ICalAttach from the data.</comment> <custom> g_return_val_if_fail (data != NULL, NULL); @@ -62,7 +54,7 @@ static void unref_g_bytes(char *data, void *user_data) </method> <method name="i_cal_attach_get_url" corresponds="icalattach_get_url" kind="others" since="1.0"> <parameter type="ICalAttach *" name="attach" comment="The #ICalAttach to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The url component of the @attach. %NULL if it is built from data or there is an error." /> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The url component of the @attach. %NULL if it is built from data or there is an error." /> <comment xml:space="preserve">Gets the url, if the #ICalAttach is built from the url.</comment> </method> <method name="i_cal_attach_get_data" corresponds="CUSTOM" kind="others" since="1.0"> diff --git a/src/libical-glib/api/i-cal-comp-iter.xml b/src/libical-glib/api/i-cal-comp-iter.xml index 549db8aa..9f690b66 100644 --- a/src/libical-glib/api/i-cal-comp-iter.xml +++ b/src/libical-glib/api/i-cal-comp-iter.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="CompIter" native="struct icalcompiter" is_bare="true" default_native="i_cal_comp_iter_new_default ()"> <method name="i_cal_comp_iter_new_default" corresponds="CUSTOM" kind="private" since="1.0" annotation="skip"> diff --git a/src/libical-glib/api/i-cal-component.xml b/src/libical-glib/api/i-cal-component.xml index 29d13e53..f466978a 100644 --- a/src/libical-glib/api/i-cal-component.xml +++ b/src/libical-glib/api/i-cal-component.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Component" native="icalcomponent" destroy_func="icalcomponent_free" includes="libical-glib/i-cal-parameter.h"> <method name="i_cal_component_new" corresponds="icalcomponent_new" kind="constructor" since="1.0"> @@ -182,32 +174,89 @@ <returns type="ICalComponent *" annotation="transfer full, nullable" translator_argus="(GObject *)component" comment="The next #ICalComponent."/> <comment xml:space="preserve">Gets the next #ICalComponent with specific kind in #ICalComponent.</comment> </method> - <method name="i_cal_component_begin_component" corresponds="icalcomponent_begin_component" since="1.0"> + <method name="i_cal_component_begin_component" corresponds="CUSTOM" since="1.0"> <parameter type="ICalComponent *" name="component" comment="A #ICalComponent"/> <parameter type="ICalComponentKind" name="kind" comment="A #ICalComponentKind"/> <returns type="ICalCompIter *" annotation="transfer full" comment="A #ICalCompIter"/> - <comment xml:space="preserve">Gets the #ICalCompIter pointing to the first child #ICalComponent. Use #ICalCompIter when you need remove the child component from the parent. For traversing, i_cal_object_set_owner needs to be called after this API. See component.py in tests for details.</comment> + <comment xml:space="preserve">Gets the #ICalCompIter pointing to the first child #ICalComponent.</comment> + <custom> ICalCompIter *iter; + + g_return_val_if_fail (I_CAL_IS_COMPONENT (component), NULL); + + iter = i_cal_comp_iter_new_full(icalcomponent_begin_component((icalcomponent *)i_cal_object_get_native(I_CAL_OBJECT (component)), (icalcomponent_kind) (kind))); + if (iter) { + i_cal_object_set_owner(I_CAL_OBJECT(iter), G_OBJECT(component)); + i_cal_object_set_always_destroy(I_CAL_OBJECT(iter), TRUE); + } + + return iter;</custom> </method> - <method name="i_cal_component_end_component" corresponds="icalcomponent_end_component" since="1.0"> + <method name="i_cal_component_end_component" corresponds="CUSTOM" since="1.0"> <parameter type="ICalComponent *" name="component" comment="A #ICalComponent"/> <parameter type="ICalComponentKind" name="kind" comment="A #ICalComponentKind"/> <returns type="ICalCompIter *" annotation="transfer full" comment="A #ICalCompIter"/> - <comment xml:space="preserve">Gets the #ICalCompIter pointing to the end child #ICalComponent. Use #ICalCompIter when you need remove the child component from the parent. For traversing, i_cal_object_set_owner needs to be called after this API. See component.py in tests for details.</comment> + <comment xml:space="preserve">Gets the #ICalCompIter pointing to the end child #ICalComponent.</comment> + <custom> ICalCompIter *iter; + g_return_val_if_fail (I_CAL_IS_COMPONENT (component), NULL); + + iter = i_cal_comp_iter_new_full(icalcomponent_end_component((icalcomponent *)i_cal_object_get_native(I_CAL_OBJECT (component)), (icalcomponent_kind) (kind))); + if (iter) { + i_cal_object_set_owner(I_CAL_OBJECT(iter), G_OBJECT(component)); + i_cal_object_set_always_destroy(I_CAL_OBJECT(iter), TRUE); + } + + return iter;</custom> </method> - <method name="i_cal_comp_iter_next" corresponds="icalcompiter_next" since="1.0"> + <method name="i_cal_comp_iter_next" corresponds="CUSTOM" since="1.0"> <parameter type="ICalCompIter *" name="i" native_op="POINTER" comment="A #ICalCompIter"/> <returns type="ICalComponent *" annotation="transfer full" comment="A #ICalCompIter"/> - <comment xml:space="preserve">Gets the next #ICalComponent pointed by #ICalCompIter. Use #ICalCompIter when you need remove the child component from the parent. For traversing, i_cal_object_set_owner needs to be called after this API. See component.py in tests for details.</comment> + <comment xml:space="preserve">Gets the next #ICalComponent pointed by #ICalCompIter.</comment> + <custom> ICalComponent *comp; + + g_return_val_if_fail (I_CAL_IS_COMP_ITER (i), NULL); + + comp = i_cal_component_new_full(icalcompiter_next((struct icalcompiter *)i_cal_object_get_native(I_CAL_OBJECT (i))), NULL); + if (comp) { + GObject *owner = i_cal_object_ref_owner(I_CAL_OBJECT(i)); + i_cal_object_set_owner(I_CAL_OBJECT(comp), owner); + g_clear_object(&owner); + } + + return comp;</custom> </method> - <method name="i_cal_comp_iter_prior" corresponds="icalcompiter_prior" since="1.0"> + <method name="i_cal_comp_iter_prior" corresponds="CUSTOM" since="1.0"> <parameter type="ICalCompIter *" name="i" native_op="POINTER" comment="A #ICalCompIter"/> <returns type="ICalComponent *" annotation="transfer full" comment="A #ICalCompIter"/> - <comment xml:space="preserve">Gets the prior #ICalComponent pointed by #ICalCompIter. Use #ICalCompIter when you need remove the child component from the parent. For traversing, i_cal_object_set_owner needs to be called after this API. See component.py in tests for details.</comment> + <comment xml:space="preserve">Gets the prior #ICalComponent pointed by #ICalCompIter.</comment> + <custom> ICalComponent *comp; + + g_return_val_if_fail (I_CAL_IS_COMP_ITER (i), NULL); + + comp = i_cal_component_new_full(icalcompiter_prior((struct icalcompiter *)i_cal_object_get_native(I_CAL_OBJECT (i))), NULL); + if (comp) { + GObject *owner = i_cal_object_ref_owner(I_CAL_OBJECT(i)); + i_cal_object_set_owner(I_CAL_OBJECT(comp), owner); + g_clear_object(&owner); + } + + return comp;</custom> </method> - <method name="i_cal_comp_iter_deref" corresponds="icalcompiter_deref" since="1.0"> + <method name="i_cal_comp_iter_deref" corresponds="CUSTOM" since="1.0"> <parameter type="ICalCompIter *" name="i" native_op="POINTER" comment="A #ICalCompIter"/> <returns type="ICalComponent *" annotation="transfer full" comment="A #ICalComponent"/> - <comment xml:space="preserve">Gets the current #ICalComponent pointed by #ICalCompIter. Use #ICalCompIter when you need remove the child component from the parent. For traversing, i_cal_object_set_owner needs to be called after this API. See component.py in tests for details.</comment> + <comment xml:space="preserve">Gets the current #ICalComponent pointed by #ICalCompIter.</comment> + <custom> ICalComponent *comp; + + g_return_val_if_fail (I_CAL_IS_COMP_ITER (i), NULL); + + comp = i_cal_component_new_full(icalcompiter_deref((struct icalcompiter *)i_cal_object_get_native(I_CAL_OBJECT (i))), NULL); + if (comp) { + GObject *owner = i_cal_object_ref_owner(I_CAL_OBJECT(i)); + i_cal_object_set_owner(I_CAL_OBJECT(comp), owner); + g_clear_object(&owner); + } + + return comp;</custom> </method> <method name="i_cal_component_check_restrictions" corresponds="icalcomponent_check_restrictions" kind="other" since="1.0"> <parameter type="ICalComponent *" name="comp" comment="The #ICalComponent to be checked"/> @@ -493,7 +542,7 @@ static void foreach_recurrence_cb(icalcomponent *in_comp, struct icaltime_span * <method name="i_cal_component_get_timezone" corresponds="icalcomponent_get_timezone" kind="get" since="1.0"> <parameter type="ICalComponent *" name="comp" comment="A #ICalComponent"/> <parameter type="const gchar *" name="tzid" comment="A string representing timezone"/> - <returns type="ICalTimezone *" annotation="transfer full, allow-none" translator_argus="(GObject *)comp, FALSE" comment="A #ICalTimezone."/> + <returns type="ICalTimezone *" annotation="transfer full, nullable" translator_argus="(GObject *)comp, FALSE" comment="A #ICalTimezone."/> <comment xml:space="preserve">Returns the icaltimezone in the component corresponding to the TZID, or NULL if it can't be found.</comment> </method> <method name="i_cal_property_recurrence_is_excluded" corresponds="icalproperty_recurrence_is_excluded" since="1.0"> diff --git a/src/libical-glib/api/i-cal-datetimeperiod.xml b/src/libical-glib/api/i-cal-datetimeperiod.xml index bfeadab1..4a393740 100644 --- a/src/libical-glib/api/i-cal-datetimeperiod.xml +++ b/src/libical-glib/api/i-cal-datetimeperiod.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Datetimeperiod" native="struct icaldatetimeperiodtype" is_bare="true" default_native="i_cal_datetimeperiod_new_default ()" includes="libical-glib/i-cal-time.h, libical-glib/i-cal-period.h"> <method name="i_cal_datetimeperiod_new_default" corresponds="CUSTOM" annotation="skip" kind="private" since="1.0"> diff --git a/src/libical-glib/api/i-cal-derived-parameter.xml b/src/libical-glib/api/i-cal-derived-parameter.xml index 1a309e4a..4b85800d 100644 --- a/src/libical-glib/api/i-cal-derived-parameter.xml +++ b/src/libical-glib/api/i-cal-derived-parameter.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="DerivedParameter"> <enum name="ICalParameterKind" native_name="icalparameter_kind" default_native="I_CAL_NO_PARAMETER"> @@ -24,13 +16,17 @@ <element name="ICAL_DELEGATEDFROM_PARAMETER"/> <element name="ICAL_DELEGATEDTO_PARAMETER"/> <element name="ICAL_DIR_PARAMETER"/> + <element name="ICAL_DISPLAY_PARAMETER"/> + <element name="ICAL_EMAIL_PARAMETER"/> <element name="ICAL_ENABLE_PARAMETER"/> <element name="ICAL_ENCODING_PARAMETER"/> <element name="ICAL_FBTYPE_PARAMETER"/> + <element name="ICAL_FEATURE_PARAMETER"/> <element name="ICAL_FILENAME_PARAMETER"/> <element name="ICAL_FMTTYPE_PARAMETER"/> <element name="ICAL_IANA_PARAMETER"/> <element name="ICAL_ID_PARAMETER"/> + <element name="ICAL_LABEL_PARAMETER"/> <element name="ICAL_LANGUAGE_PARAMETER"/> <element name="ICAL_LATENCY_PARAMETER"/> <element name="ICAL_LOCAL_PARAMETER"/> @@ -40,6 +36,7 @@ <element name="ICAL_MODIFIED_PARAMETER"/> <element name="ICAL_OPTIONS_PARAMETER"/> <element name="ICAL_PARTSTAT_PARAMETER"/> + <element name="ICAL_PATCHACTION_PARAMETER"/> <element name="ICAL_PUBLICCOMMENT_PARAMETER"/> <element name="ICAL_RANGE_PARAMETER"/> <element name="ICAL_REASON_PARAMETER"/> @@ -78,6 +75,14 @@ <element name="ICAL_CUTYPE_UNKNOWN"/> <element name="ICAL_CUTYPE_NONE"/> </enum> + <enum name="ICalParameterDisplay" native_name="icalparameter_display" default_native="I_CAL_DISPLAY_NONE"> + <element name="ICAL_DISPLAY_X"/> + <element name="ICAL_DISPLAY_BADGE"/> + <element name="ICAL_DISPLAY_GRAPHIC"/> + <element name="ICAL_DISPLAY_FULLSIZE"/> + <element name="ICAL_DISPLAY_THUMBNAIL"/> + <element name="ICAL_DISPLAY_NONE"/> + </enum> <enum name="ICalParameterEnable" native_name="icalparameter_enable" default_native="I_CAL_ENABLE_NONE"> <element name="ICAL_ENABLE_X"/> <element name="ICAL_ENABLE_TRUE"/> @@ -98,6 +103,17 @@ <element name="ICAL_FBTYPE_BUSYTENTATIVE"/> <element name="ICAL_FBTYPE_NONE"/> </enum> + <enum name="ICalParameterFeature" native_name="icalparameter_feature" default_native="I_CAL_FEATURE_NONE"> + <element name="ICAL_FEATURE_X"/> + <element name="ICAL_FEATURE_AUDIO"/> + <element name="ICAL_FEATURE_CHAT"/> + <element name="ICAL_FEATURE_FEED"/> + <element name="ICAL_FEATURE_MODERATOR"/> + <element name="ICAL_FEATURE_PHONE"/> + <element name="ICAL_FEATURE_SCREEN"/> + <element name="ICAL_FEATURE_VIDEO"/> + <element name="ICAL_FEATURE_NONE"/> + </enum> <enum name="ICalParameterLocal" native_name="icalparameter_local" default_native="I_CAL_LOCAL_NONE"> <element name="ICAL_LOCAL_X"/> <element name="ICAL_LOCAL_TRUE"/> @@ -116,6 +132,14 @@ <element name="ICAL_PARTSTAT_FAILED"/> <element name="ICAL_PARTSTAT_NONE"/> </enum> + <enum name="ICalParameterPatchaction" native_name="icalparameter_patchaction" default_native="I_CAL_PATCHACTION_NONE"> + <element name="ICAL_PATCHACTION_X"/> + <element name="ICAL_PATCHACTION_CREATE"/> + <element name="ICAL_PATCHACTION_BYNAME"/> + <element name="ICAL_PATCHACTION_BYVALUE"/> + <element name="ICAL_PATCHACTION_BYPARAM"/> + <element name="ICAL_PATCHACTION_NONE"/> + </enum> <enum name="ICalParameterRange" native_name="icalparameter_range" default_native="I_CAL_RANGE_NONE"> <element name="ICAL_RANGE_X"/> <element name="ICAL_RANGE_THISANDPRIOR"/> @@ -247,7 +271,7 @@ </method> <method name="i_cal_parameter_get_altrep" corresponds="icalparameter_get_altrep" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_altrep" corresponds="icalparameter_set_altrep" kind="set" since="1.0"> @@ -262,7 +286,7 @@ </method> <method name="i_cal_parameter_get_charset" corresponds="icalparameter_get_charset" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_charset" corresponds="icalparameter_set_charset" kind="set" since="1.0"> @@ -277,7 +301,7 @@ </method> <method name="i_cal_parameter_get_cn" corresponds="icalparameter_get_cn" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_cn" corresponds="icalparameter_set_cn" kind="set" since="1.0"> @@ -292,7 +316,7 @@ </method> <method name="i_cal_parameter_get_cutype" corresponds="icalparameter_get_cutype" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="ICalParameterCutype" annotation="allow-none" comment="The property of the @value" /> + <returns type="ICalParameterCutype" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_cutype" corresponds="icalparameter_set_cutype" kind="set" since="1.0"> @@ -307,7 +331,7 @@ </method> <method name="i_cal_parameter_get_delegatedfrom" corresponds="icalparameter_get_delegatedfrom" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_delegatedfrom" corresponds="icalparameter_set_delegatedfrom" kind="set" since="1.0"> @@ -322,7 +346,7 @@ </method> <method name="i_cal_parameter_get_delegatedto" corresponds="icalparameter_get_delegatedto" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_delegatedto" corresponds="icalparameter_set_delegatedto" kind="set" since="1.0"> @@ -337,7 +361,7 @@ </method> <method name="i_cal_parameter_get_dir" corresponds="icalparameter_get_dir" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_dir" corresponds="icalparameter_set_dir" kind="set" since="1.0"> @@ -345,6 +369,36 @@ <parameter type="const gchar *" name="v" comment="The string used to set into the @value"/> <comment xml:space="preserve"></comment> </method> + <method name="i_cal_parameter_new_display" corresponds="icalparameter_new_display" kind="constructor" since="3.0.15"> + <parameter type="ICalParameterDisplay" name="value" comment="The #ICalParameterDisplay value of the new #ICalParameter"/> + <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter" /> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_get_display" corresponds="icalparameter_get_display" kind="get" since="3.0.15"> + <parameter type="const ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> + <returns type="ICalParameterDisplay" comment="The #ICalParameterDisplay value of the @param"/> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_set_display" corresponds="icalparameter_set_display" kind="set" since="3.0.15"> + <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be set"/> + <parameter type="ICalParameterDisplay" name="value" comment="The #ICalParameterDisplay to set into the @param"/> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_new_email" corresponds="icalparameter_new_email" kind="constructor" since="3.0.15"> + <parameter type="const gchar *" name="value" comment="The string value of the new #ICalParameter"/> + <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter" /> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_get_email" corresponds="icalparameter_get_email" kind="get" since="3.0.15"> + <parameter type="const ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> + <returns type="const gchar *" annotation="nullable" comment="The string value of the @param"/> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_set_email" corresponds="icalparameter_set_email" kind="set" since="3.0.15"> + <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be set"/> + <parameter type="const gchar *" name="value" comment="The string value to set into the @param"/> + <comment xml:space="preserve"></comment> + </method> <method name="i_cal_parameter_new_enable" corresponds="icalparameter_new_enable" kind="constructor" since="1.0"> <parameter type="ICalParameterEnable" name="v" comment="The type of #ICalParameter to be created"/> <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter." /> @@ -390,6 +444,21 @@ <parameter type="ICalParameterFbtype" name="v" comment="The type of #ICalParameter to be set in the @value"/> <comment xml:space="preserve"></comment> </method> + <method name="i_cal_parameter_new_feature" corresponds="icalparameter_new_feature" kind="constructor" since="3.0.15"> + <parameter type="ICalParameterFeature" name="value" comment="The #ICalParameterFeature value of the new #ICalParameter"/> + <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter" /> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_get_feature" corresponds="icalparameter_get_feature" kind="get" since="3.0.15"> + <parameter type="const ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> + <returns type="ICalParameterFeature" comment="The #ICalParameterFeature value of the @param"/> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_set_feature" corresponds="icalparameter_set_feature" kind="set" since="3.0.15"> + <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be set"/> + <parameter type="ICalParameterFeature" name="value" comment="The #ICalParameterFeature to set into the @param"/> + <comment xml:space="preserve"></comment> + </method> <method name="i_cal_parameter_new_filename" corresponds="icalparameter_new_filename" kind="constructor" since="2.0"> <parameter type="const gchar *" name="v" comment="The string used to create the new #ICalParameter"/> <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter." /> @@ -397,7 +466,7 @@ </method> <method name="i_cal_parameter_get_filename" corresponds="icalparameter_get_filename" kind="get" since="2.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_filename" corresponds="icalparameter_set_filename" kind="set" since="2.0"> @@ -412,7 +481,7 @@ </method> <method name="i_cal_parameter_get_fmttype" corresponds="icalparameter_get_fmttype" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_fmttype" corresponds="icalparameter_set_fmttype" kind="set" since="1.0"> @@ -427,7 +496,7 @@ </method> <method name="i_cal_parameter_get_iana" corresponds="icalparameter_get_iana" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_iana" corresponds="icalparameter_set_iana" kind="set" since="1.0"> @@ -442,7 +511,7 @@ </method> <method name="i_cal_parameter_get_id" corresponds="icalparameter_get_id" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_id" corresponds="icalparameter_set_id" kind="set" since="1.0"> @@ -450,6 +519,21 @@ <parameter type="const gchar *" name="v" comment="The string used to set into the @value"/> <comment xml:space="preserve"></comment> </method> + <method name="i_cal_parameter_new_label" corresponds="icalparameter_new_label" kind="constructor" since="3.0.15"> + <parameter type="const gchar *" name="value" comment="The string value of the new #ICalParameter"/> + <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter" /> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_get_label" corresponds="icalparameter_get_label" kind="get" since="3.0.15"> + <parameter type="const ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> + <returns type="const gchar *" annotation="nullable" comment="The string value of the @param"/> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_set_label" corresponds="icalparameter_set_label" kind="set" since="3.0.15"> + <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be set"/> + <parameter type="const gchar *" name="value" comment="The string value to set into the @param"/> + <comment xml:space="preserve"></comment> + </method> <method name="i_cal_parameter_new_language" corresponds="icalparameter_new_language" kind="constructor" since="1.0"> <parameter type="const gchar *" name="v" comment="The string used to create the new #ICalParameter"/> <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter." /> @@ -457,7 +541,7 @@ </method> <method name="i_cal_parameter_get_language" corresponds="icalparameter_get_language" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_language" corresponds="icalparameter_set_language" kind="set" since="1.0"> @@ -472,7 +556,7 @@ </method> <method name="i_cal_parameter_get_latency" corresponds="icalparameter_get_latency" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_latency" corresponds="icalparameter_set_latency" kind="set" since="1.0"> @@ -502,7 +586,7 @@ </method> <method name="i_cal_parameter_get_localize" corresponds="icalparameter_get_localize" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_localize" corresponds="icalparameter_set_localize" kind="set" since="1.0"> @@ -517,7 +601,7 @@ </method> <method name="i_cal_parameter_get_managedid" corresponds="icalparameter_get_managedid" kind="get" since="2.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_managedid" corresponds="icalparameter_set_managedid" kind="set" since="2.0"> @@ -532,7 +616,7 @@ </method> <method name="i_cal_parameter_get_member" corresponds="icalparameter_get_member" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_member" corresponds="icalparameter_set_member" kind="set" since="1.0"> @@ -547,7 +631,7 @@ </method> <method name="i_cal_parameter_get_modified" corresponds="icalparameter_get_modified" kind="get" since="2.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_modified" corresponds="icalparameter_set_modified" kind="set" since="2.0"> @@ -562,7 +646,7 @@ </method> <method name="i_cal_parameter_get_options" corresponds="icalparameter_get_options" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_options" corresponds="icalparameter_set_options" kind="set" since="1.0"> @@ -585,6 +669,21 @@ <parameter type="ICalParameterPartstat" name="v" comment="The type of #ICalParameter to be set in the @value"/> <comment xml:space="preserve"></comment> </method> + <method name="i_cal_parameter_new_patchaction" corresponds="icalparameter_new_patchaction" kind="constructor" since="3.0.15"> + <parameter type="ICalParameterPatchaction" name="value" comment="The #ICalParameterPatchaction value of the new #ICalParameter"/> + <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter" /> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_get_patchaction" corresponds="icalparameter_get_patchaction" kind="get" since="3.0.15"> + <parameter type="const ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> + <returns type="ICalParameterPatchaction" comment="The #ICalParameterPatchaction value of the @param"/> + <comment xml:space="preserve"></comment> + </method> + <method name="i_cal_parameter_set_patchaction" corresponds="icalparameter_set_patchaction" kind="set" since="3.0.15"> + <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be set"/> + <parameter type="ICalParameterPatchaction" name="value" comment="The #ICalParameterPatchaction to set into the @param"/> + <comment xml:space="preserve"></comment> + </method> <method name="i_cal_parameter_new_publiccomment" corresponds="icalparameter_new_publiccomment" kind="constructor" since="2.0"> <parameter type="const gchar *" name="v" comment="The string used to create the new #ICalParameter"/> <returns type="ICalParameter *" annotation="transfer full" comment="The newly created #ICalParameter." /> @@ -592,7 +691,7 @@ </method> <method name="i_cal_parameter_get_publiccomment" corresponds="icalparameter_get_publiccomment" kind="get" since="2.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_publiccomment" corresponds="icalparameter_set_publiccomment" kind="set" since="2.0"> @@ -622,7 +721,7 @@ </method> <method name="i_cal_parameter_get_reason" corresponds="icalparameter_get_reason" kind="get" since="2.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_reason" corresponds="icalparameter_set_reason" kind="set" since="2.0"> @@ -757,7 +856,7 @@ </method> <method name="i_cal_parameter_get_schedulestatus" corresponds="icalparameter_get_schedulestatus" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_schedulestatus" corresponds="icalparameter_set_schedulestatus" kind="set" since="1.0"> @@ -772,7 +871,7 @@ </method> <method name="i_cal_parameter_get_sentby" corresponds="icalparameter_get_sentby" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_sentby" corresponds="icalparameter_set_sentby" kind="set" since="1.0"> @@ -787,7 +886,7 @@ </method> <method name="i_cal_parameter_get_size" corresponds="icalparameter_get_size" kind="get" since="2.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_size" corresponds="icalparameter_set_size" kind="set" since="2.0"> @@ -832,7 +931,7 @@ </method> <method name="i_cal_parameter_get_tzid" corresponds="icalparameter_get_tzid" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_tzid" corresponds="icalparameter_set_tzid" kind="set" since="1.0"> @@ -862,7 +961,7 @@ </method> <method name="i_cal_parameter_get_x" corresponds="icalparameter_get_x" kind="get" since="1.0"> <parameter type="const ICalParameter *" name="value" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve"></comment> </method> <method name="i_cal_parameter_set_x" corresponds="icalparameter_set_x" kind="set" since="1.0"> diff --git a/src/libical-glib/api/i-cal-derived-property.xml b/src/libical-glib/api/i-cal-derived-property.xml index 24e31ef5..3ca15403 100644 --- a/src/libical-glib/api/i-cal-derived-property.xml +++ b/src/libical-glib/api/i-cal-derived-property.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="DerivedProperty"> <enum name="ICalPropertyKind" native_name="icalproperty_kind" default_native="I_CAL_NO_PROPERTY"> diff --git a/src/libical-glib/api/i-cal-derived-value.xml b/src/libical-glib/api/i-cal-derived-value.xml index aa58a233..92d94b8a 100644 --- a/src/libical-glib/api/i-cal-derived-value.xml +++ b/src/libical-glib/api/i-cal-derived-value.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="DerivedValue"> <enum name="ICalValueKind" native_name="icalvalue_kind" default_native="I_CAL_NO_VALUE"> @@ -210,7 +202,7 @@ </method> <method name="i_cal_value_get_x" corresponds="icalvalue_get_x" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The x within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The x within #ICalValue"/> <comment>Gets the x of #ICalValue.</comment> </method> <method name="i_cal_value_set_recur" corresponds="icalvalue_set_recur" kind="set" since="1.0"> @@ -225,7 +217,7 @@ </method> <method name="i_cal_value_get_recur" corresponds="icalvalue_get_recur" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalRecurrence *" annotation="allow-none, transfer full" comment="The recur within #ICalValue"/> + <returns type="ICalRecurrence *" annotation="nullable, transfer full" comment="The recur within #ICalValue"/> <comment>Gets the recur of #ICalValue.</comment> </method> <method name="i_cal_value_set_trigger" corresponds="icalvalue_set_trigger" kind="set" since="1.0"> @@ -240,7 +232,7 @@ </method> <method name="i_cal_value_get_trigger" corresponds="icalvalue_get_trigger" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalTrigger *" annotation="allow-none, transfer full" comment="The trigger within #ICalValue"/> + <returns type="ICalTrigger *" annotation="nullable, transfer full" comment="The trigger within #ICalValue"/> <comment>Gets the trigger of #ICalValue.</comment> </method> <method name="i_cal_value_set_datetime" corresponds="icalvalue_set_datetime" kind="set" since="1.0"> @@ -255,7 +247,7 @@ </method> <method name="i_cal_value_get_datetime" corresponds="icalvalue_get_datetime" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalTime *" annotation="allow-none, transfer full" comment="The datetime within #ICalValue"/> + <returns type="ICalTime *" annotation="nullable, transfer full" comment="The datetime within #ICalValue"/> <comment>Gets the datetime of #ICalValue.</comment> </method> <method name="i_cal_value_set_datetimedate" corresponds="icalvalue_set_datetimedate" kind="set" since="3.0"> @@ -270,7 +262,7 @@ </method> <method name="i_cal_value_get_datetimedate" corresponds="icalvalue_get_datetimedate" kind="get" since="3.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalTime *" annotation="allow-none, transfer full" comment="The datetimedate within #ICalValue"/> + <returns type="ICalTime *" annotation="nullable, transfer full" comment="The datetimedate within #ICalValue"/> <comment>Gets the datetimedate (DATE-TIME or DATE) of #ICalValue.</comment> </method> <method name="i_cal_value_set_datetimeperiod" corresponds="icalvalue_set_datetimeperiod" kind="set" since="1.0"> @@ -285,7 +277,7 @@ </method> <method name="i_cal_value_get_datetimeperiod" corresponds="icalvalue_get_datetimeperiod" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalDatetimeperiod *" annotation="allow-none, transfer full" comment="The datetimeperiod within #ICalValue"/> + <returns type="ICalDatetimeperiod *" annotation="nullable, transfer full" comment="The datetimeperiod within #ICalValue"/> <comment>Gets the datetimeperiod of #ICalValue.</comment> </method> <method name="i_cal_value_set_geo" corresponds="icalvalue_set_geo" kind="set" since="1.0"> @@ -300,7 +292,7 @@ </method> <method name="i_cal_value_get_geo" corresponds="icalvalue_get_geo" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalGeo *" annotation="allow-none, transfer full" comment="The geo within #ICalValue"/> + <returns type="ICalGeo *" annotation="nullable, transfer full" comment="The geo within #ICalValue"/> <comment>Gets the geo of #ICalValue.</comment> </method> <method name="i_cal_value_set_attach" corresponds="icalvalue_set_attach" kind="set" since="1.0"> @@ -315,7 +307,7 @@ </method> <method name="i_cal_value_get_attach" corresponds="icalvalue_get_attach" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalAttach *" annotation="allow-none, transfer none" translator_argus="(GObject *)value" comment="The attach within #ICalValue"/> + <returns type="ICalAttach *" annotation="nullable, transfer none" translator_argus="(GObject *)value" comment="The attach within #ICalValue"/> <comment>Gets the attach of #ICalValue.</comment> </method> <method name="i_cal_value_reset_kind" corresponds="icalvalue_reset_kind" kind="other" since="1.0"> @@ -454,7 +446,7 @@ </method> <method name="i_cal_value_get_caladdress" corresponds="icalvalue_get_caladdress" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The caladdress within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The caladdress within #ICalValue"/> <comment>Gets the caladdress of #ICalValue.</comment> </method> <method name="i_cal_value_set_period" corresponds="icalvalue_set_period" kind="set" since="1.0"> @@ -469,7 +461,7 @@ </method> <method name="i_cal_value_get_period" corresponds="icalvalue_get_period" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalPeriod *" annotation="allow-none, transfer full" comment="The period within #ICalValue"/> + <returns type="ICalPeriod *" annotation="nullable, transfer full" comment="The period within #ICalValue"/> <comment>Gets the period of #ICalValue.</comment> </method> <method name="i_cal_value_set_status" corresponds="icalvalue_set_status" kind="set" since="1.0"> @@ -499,7 +491,7 @@ </method> <method name="i_cal_value_get_binary" corresponds="icalvalue_get_binary" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The binary within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The binary within #ICalValue"/> <comment>Gets the binary of #ICalValue.</comment> </method> <method name="i_cal_value_set_text" corresponds="icalvalue_set_text" kind="set" since="1.0"> @@ -514,7 +506,7 @@ </method> <method name="i_cal_value_get_text" corresponds="icalvalue_get_text" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The text within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The text within #ICalValue"/> <comment>Gets the text of #ICalValue.</comment> </method> <method name="i_cal_value_set_duration" corresponds="icalvalue_set_duration" kind="set" since="1.0"> @@ -529,7 +521,7 @@ </method> <method name="i_cal_value_get_duration" corresponds="icalvalue_get_duration" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalDuration *" annotation="allow-none, transfer full" comment="The duration within #ICalValue"/> + <returns type="ICalDuration *" annotation="nullable, transfer full" comment="The duration within #ICalValue"/> <comment>Gets the duration of #ICalValue.</comment> </method> <method name="i_cal_value_set_integer" corresponds="icalvalue_set_integer" kind="set" since="1.0"> @@ -559,7 +551,7 @@ </method> <method name="i_cal_value_get_uri" corresponds="icalvalue_get_uri" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The uri within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The uri within #ICalValue"/> <comment>Gets the uri of #ICalValue.</comment> </method> <method name="i_cal_value_set_class" corresponds="icalvalue_set_class" kind="set" since="1.0"> @@ -604,7 +596,7 @@ </method> <method name="i_cal_value_get_query" corresponds="icalvalue_get_query" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The query within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The query within #ICalValue"/> <comment>Gets the query of #ICalValue.</comment> </method> <method name="i_cal_value_set_string" corresponds="icalvalue_set_string" kind="set" since="1.0"> @@ -619,7 +611,7 @@ </method> <method name="i_cal_value_get_string" corresponds="icalvalue_get_string" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The string within #ICalValue"/> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The string within #ICalValue"/> <comment>Gets the string of #ICalValue.</comment> </method> <method name="i_cal_value_set_transp" corresponds="icalvalue_set_transp" kind="set" since="1.0"> @@ -649,7 +641,7 @@ </method> <method name="i_cal_value_get_requeststatus" corresponds="icalvalue_get_requeststatus" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalReqstat *" annotation="allow-none, transfer full" comment="The requeststatus within #ICalValue"/> + <returns type="ICalReqstat *" annotation="nullable, transfer full" comment="The requeststatus within #ICalValue"/> <comment>Gets the requeststatus of #ICalValue.</comment> </method> <method name="i_cal_value_set_date" corresponds="icalvalue_set_date" kind="set" since="1.0"> @@ -664,7 +656,7 @@ </method> <method name="i_cal_value_get_date" corresponds="icalvalue_get_date" kind="get" since="1.0"> <parameter type="ICalValue *" name="value" comment="The #ICalValue to be queried"/> - <returns type="ICalTime *" annotation="allow-none, transfer full" comment="The date within #ICalValue"/> + <returns type="ICalTime *" annotation="nullable, transfer full" comment="The date within #ICalValue"/> <comment>Gets the date of #ICalValue.</comment> </method> <method name="i_cal_value_set_action" corresponds="icalvalue_set_action" kind="set" since="1.0"> diff --git a/src/libical-glib/api/i-cal-duration.xml b/src/libical-glib/api/i-cal-duration.xml index ec80208d..053cbee5 100644 --- a/src/libical-glib/api/i-cal-duration.xml +++ b/src/libical-glib/api/i-cal-duration.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Duration" native="struct icaldurationtype" is_bare="true" default_native="icaldurationtype_null_duration()"> <method name="i_cal_duration_is_neg" corresponds="CUSTOM" kind="get" since="1.0"> diff --git a/src/libical-glib/api/i-cal-enums.xml b/src/libical-glib/api/i-cal-enums.xml index 61e12a79..ac8a747a 100644 --- a/src/libical-glib/api/i-cal-enums.xml +++ b/src/libical-glib/api/i-cal-enums.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Enums"> <enum name="ICalComponentKind" native_name="icalcomponent_kind" default_native="I_CAL_NO_COMPONENT"> diff --git a/src/libical-glib/api/i-cal-error.xml b/src/libical-glib/api/i-cal-error.xml index e2692f71..9589ddd5 100644 --- a/src/libical-glib/api/i-cal-error.xml +++ b/src/libical-glib/api/i-cal-error.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Error"> <enum name="ICalErrorEnum" native_name="icalerrorenum" default_native="I_CAL_UNKNOWN_ERROR"> diff --git a/src/libical-glib/api/i-cal-geo.xml b/src/libical-glib/api/i-cal-geo.xml index 4d531387..b7645184 100644 --- a/src/libical-glib/api/i-cal-geo.xml +++ b/src/libical-glib/api/i-cal-geo.xml @@ -1,25 +1,17 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Geo" native="struct icalgeotype" is_bare="true" default_native="i_cal_geo_new_default ()"> <method name="i_cal_geo_new_default" corresponds="CUSTOM" annotation="skip" kind="private" since="1.0"> <returns type="struct icalgeotype" annotation="transfer full" comment="The newly created #ICalGeo" /> <comment xml:space="preserve">Creates a new default #ICalGeo.</comment> <custom> struct icalgeotype geotype; - geotype.lat = 0; - geotype.lon = 0; + memset(geotype.lat, 0, ICAL_GEO_LEN); + memset(geotype.lon, 0, ICAL_GEO_LEN); return geotype;</custom> </method> <method name="i_cal_geo_new" corresponds="CUSTOM" kind="constructor" since="1.0"> @@ -28,10 +20,14 @@ <returns type="ICalGeo *" annotation="transfer full" comment="The newly created #ICalGeo." /> <comment xml:space="preserve">Creates a new #ICalGeo.</comment> <custom> struct icalgeotype geo; - + char dval[ICAL_GEO_LEN]; geo = i_cal_geo_new_default(); - geo.lat = lat; - geo.lon = lon; + memset(dval, 0, ICAL_GEO_LEN); + snprintf(dval, ICAL_GEO_LEN, "%lf", lat); + strncpy(geo.lat, dval, ICAL_GEO_LEN-1); + memset(dval, 0, ICAL_GEO_LEN); + snprintf(dval, ICAL_GEO_LEN, "%lf", lon); + strncpy(geo.lon, dval, ICAL_GEO_LEN-1); return i_cal_geo_new_full(geo);</custom> </method> @@ -53,27 +49,33 @@ <returns type="gdouble" comment="The latitude." /> <comment xml:space="preserve">Gets the latitude of #ICalGeo.</comment> <custom> g_return_val_if_fail (geo != NULL, 0); - return ((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lat;</custom> + return atof(((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lat);</custom> </method> <method name="i_cal_geo_set_lat" corresponds="CUSTOM" kind="set" since="1.0"> <parameter type="ICalGeo *" name="geo" comment="The #ICalGeo to be set"/> <parameter type="gdouble" name="lat" comment="The latitude"/> <comment>Sets the latitude of #ICalGeo.</comment> - <custom> g_return_if_fail (geo != NULL && I_CAL_IS_GEO (geo)); - ((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lat = lat;</custom> + <custom> char dval[ICAL_GEO_LEN]; + g_return_if_fail (geo != NULL && I_CAL_IS_GEO (geo)); + memset(dval, 0, ICAL_GEO_LEN); + snprintf(dval, ICAL_GEO_LEN, "%lf", lat); + strncpy(((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lat, dval, ICAL_GEO_LEN-1);</custom> </method> <method name="i_cal_geo_get_lon" corresponds="CUSTOM" kind="get" since="1.0"> <parameter type="ICalGeo *" name="geo" comment="The #ICalGeo to be queried"/> <returns type="gdouble" comment="The longitude." /> <comment xml:space="preserve">Gets the longitude of #ICalGeo.</comment> <custom> g_return_val_if_fail (geo != NULL, 0); - return ((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lon;</custom> + return atof(((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lon);</custom> </method> <method name="i_cal_geo_set_lon" corresponds="CUSTOM" kind="set" since="1.0"> <parameter type="ICalGeo *" name="geo" comment="The #ICalGeo to be set"/> <parameter type="gdouble" name="lon" comment="The longitude"/> <comment>Sets the longitude of #ICalGeo.</comment> - <custom> g_return_if_fail (geo != NULL && I_CAL_IS_GEO (geo)); - ((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lon = lon;</custom> + <custom> char dval[ICAL_GEO_LEN]; + g_return_if_fail (geo != NULL && I_CAL_IS_GEO (geo)); + memset(dval, 0, ICAL_GEO_LEN); + snprintf(dval, ICAL_GEO_LEN, "%lf", lon); + strncpy(((struct icalgeotype *)i_cal_object_get_native ((ICalObject *)geo))->lon, dval, ICAL_GEO_LEN-1);</custom> </method> </structure> diff --git a/src/libical-glib/api/i-cal-memory.xml b/src/libical-glib/api/i-cal-memory.xml index 49980a60..ffb2cac0 100644 --- a/src/libical-glib/api/i-cal-memory.xml +++ b/src/libical-glib/api/i-cal-memory.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Memory"> <method name="i_cal_memory_tmp_buffer" corresponds="icalmemory_tmp_buffer" since="1.0"> diff --git a/src/libical-glib/api/i-cal-mime.xml b/src/libical-glib/api/i-cal-mime.xml index 2fa40f9f..f2b1ff3c 100644 --- a/src/libical-glib/api/i-cal-mime.xml +++ b/src/libical-glib/api/i-cal-mime.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Mime"> <declaration position="header">/** diff --git a/src/libical-glib/api/i-cal-parameter.xml b/src/libical-glib/api/i-cal-parameter.xml index c8bddb91..a3a6f919 100644 --- a/src/libical-glib/api/i-cal-parameter.xml +++ b/src/libical-glib/api/i-cal-parameter.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Parameter" native="icalparameter" destroy_func="icalparameter_free"> <method name="i_cal_parameter_new" corresponds="icalparameter_new" kind="constructor" since="1.0"> @@ -61,7 +53,7 @@ </method> <method name="i_cal_parameter_get_xname" corresponds="icalparameter_get_xname" kind="get" since="1.0"> <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve">Gets the xname property of the native part of the #ICalParameter.</comment> </method> <method name="i_cal_parameter_set_xvalue" corresponds="icalparameter_set_xvalue" kind="set" since="1.0"> @@ -71,7 +63,7 @@ </method> <method name="i_cal_parameter_get_xvalue" corresponds="icalparameter_get_xvalue" kind="get" since="1.0"> <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve">Gets the xvalue property of the native part of the #ICalParameter.</comment> </method> <method name="i_cal_parameter_set_iana_name" corresponds="icalparameter_set_iana_name" kind="set" since="1.0"> @@ -81,7 +73,7 @@ </method> <method name="i_cal_parameter_get_iana_name" corresponds="icalparameter_get_iana_name" kind="get" since="1.0"> <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve">Gets the iana_name property of the native part of the #ICalParameter.</comment> </method> <method name="i_cal_parameter_set_iana_value" corresponds="icalparameter_set_iana_value" kind="set" since="1.0"> @@ -91,7 +83,7 @@ </method> <method name="i_cal_parameter_get_iana_value" corresponds="icalparameter_get_iana_value" kind="get" since="1.0"> <parameter type="ICalParameter *" name="param" comment="The #ICalParameter to be queried"/> - <returns type="const gchar *" annotation="allow-none" comment="The property of the @value" /> + <returns type="const gchar *" annotation="nullable" comment="The property of the @value" /> <comment xml:space="preserve">Gets the iana_value property of the native part of the #ICalParameter.</comment> </method> <method name="i_cal_parameter_has_same_name" corresponds="icalparameter_has_same_name" kind="others" since="1.0"> diff --git a/src/libical-glib/api/i-cal-parser.xml b/src/libical-glib/api/i-cal-parser.xml index 7e901de2..7bca47fa 100644 --- a/src/libical-glib/api/i-cal-parser.xml +++ b/src/libical-glib/api/i-cal-parser.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Parser" native="icalparser" destroy_func="icalparser_free"> <enum name="ICalParserState" native_name="icalparserstate" default_native="I_CAL_PARSER_ERROR"> @@ -36,13 +28,13 @@ typedef gchar *(*ICalParserLineGenFunc)(gchar *bytes, size_t size, gpointer user </method> <method name="i_cal_parser_add_line" corresponds="icalparser_add_line" since="1.0"> <parameter type="ICalParser *" name="parser" annotation="in, transfer full" comment="The #ICalParser used to parse the string into the #ICalComponent"/> - <parameter type="gchar *" name="str" annotation="allow-none, transfer none" comment="A line of string representation of the #ICalComponent"/> - <returns type="ICalComponent *" annotation="allow-none, transfer full" translator_argus="(gpointer) parser" comment="The complete #ICalComponent."/> + <parameter type="gchar *" name="str" annotation="nullable, transfer none" comment="A line of string representation of the #ICalComponent"/> + <returns type="ICalComponent *" annotation="nullable, transfer full" translator_argus="(gpointer) parser" comment="The complete #ICalComponent."/> <comment xml:space="preserve">Add a line at one time into the #ICalParser until the parsing is complete and #ICalComponent will be returned.</comment> </method> <method name="i_cal_parser_clean" corresponds="icalparser_clean" since="1.0"> <parameter type="ICalParser *" name="parser" comment="The parser to be cleaned and queried"/> - <returns type="ICalComponent *" annotation="allow-none, transfer full" translator_argus="(gpointer) parser" comment="The root #ICalComponent in @parser."/> + <returns type="ICalComponent *" annotation="nullable, transfer full" translator_argus="(gpointer) parser" comment="The root #ICalComponent in @parser."/> <comment xml:space="preserve">We won't get a clean exit if some components did not have an "END" tag. Clear off any component that may be left in the list.</comment> </method> <method name="i_cal_parser_get_state" corresponds="icalparser_get_state" kind="get" since="1.0"> diff --git a/src/libical-glib/api/i-cal-period.xml b/src/libical-glib/api/i-cal-period.xml index 1b02bbc6..8e3fc2ca 100644 --- a/src/libical-glib/api/i-cal-period.xml +++ b/src/libical-glib/api/i-cal-period.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Period" native="struct icalperiodtype" is_bare="true" default_native="icalperiodtype_null_period ()"> <method name="i_cal_period_get_start" corresponds="CUSTOM" kind="get" since="1.0"> diff --git a/src/libical-glib/api/i-cal-property.xml b/src/libical-glib/api/i-cal-property.xml index 4d4151a7..5e874b66 100644 --- a/src/libical-glib/api/i-cal-property.xml +++ b/src/libical-glib/api/i-cal-property.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Property" native="icalproperty" destroy_func="icalproperty_free"> <method name="i_cal_property_new" corresponds="icalproperty_new" kind="constructor" since="1.0"> diff --git a/src/libical-glib/api/i-cal-recur-iterator.xml b/src/libical-glib/api/i-cal-recur-iterator.xml index 032c4257..7e0ad916 100644 --- a/src/libical-glib/api/i-cal-recur-iterator.xml +++ b/src/libical-glib/api/i-cal-recur-iterator.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="RecurIterator" native="icalrecur_iterator" destroy_func="icalrecur_iterator_free"> <method name="i_cal_recur_iterator_new" corresponds="icalrecur_iterator_new" kind="constructor" since="1.0"> diff --git a/src/libical-glib/api/i-cal-recur.xml b/src/libical-glib/api/i-cal-recur.xml index 870ea61b..e1d689b4 100644 --- a/src/libical-glib/api/i-cal-recur.xml +++ b/src/libical-glib/api/i-cal-recur.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Recur"> <method name="i_cal_recur_expand_recurrence" corresponds="CUSTOM" since="1.0"> diff --git a/src/libical-glib/api/i-cal-recurrence.xml b/src/libical-glib/api/i-cal-recurrence.xml index 0ebb4545..ce019dd4 100644 --- a/src/libical-glib/api/i-cal-recurrence.xml +++ b/src/libical-glib/api/i-cal-recurrence.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Recurrence" native="struct icalrecurrencetype" is_bare="true" default_native="i_cal_recurrence_new_default ()"> <enum name="ICalRecurrenceFrequency" native_name="icalrecurrencetype_frequency" default_native="I_CAL_NO_RECURRENCE"> diff --git a/src/libical-glib/api/i-cal-reqstat.xml b/src/libical-glib/api/i-cal-reqstat.xml index 738c8a32..dbbdd061 100644 --- a/src/libical-glib/api/i-cal-reqstat.xml +++ b/src/libical-glib/api/i-cal-reqstat.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Reqstat" native="struct icalreqstattype" is_bare="true" default_native="i_cal_reqstat_new_default ()"> <method name="i_cal_reqstat_new_from_string" corresponds="icalreqstattype_from_string" kind="constructor" since="1.0"> diff --git a/src/libical-glib/api/i-cal-restriction.xml b/src/libical-glib/api/i-cal-restriction.xml index 5bc4fe40..77fb117f 100644 --- a/src/libical-glib/api/i-cal-restriction.xml +++ b/src/libical-glib/api/i-cal-restriction.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Restriction"> <enum name="ICalRestrictionKind" native_name="icalrestriction_kind" default_native="I_CAL_RESTRICTION_UNKNOWN"> diff --git a/src/libical-glib/api/i-cal-time-span.xml b/src/libical-glib/api/i-cal-time-span.xml index 4c2aae18..ca8cfe9e 100644 --- a/src/libical-glib/api/i-cal-time-span.xml +++ b/src/libical-glib/api/i-cal-time-span.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="TimeSpan" native="struct icaltime_span" is_bare="true" default_native="icaltime_span_new(icaltime_null_time(), icaltime_null_time(), 0)" includes="libical-glib/i-cal-time.h"> <method name="i_cal_time_span_new_timet" corresponds="CUSTOM" kind="constructor" since="3.0.5"> diff --git a/src/libical-glib/api/i-cal-time.xml b/src/libical-glib/api/i-cal-time.xml index be6e2685..678be801 100644 --- a/src/libical-glib/api/i-cal-time.xml +++ b/src/libical-glib/api/i-cal-time.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Time" native="struct icaltimetype" is_bare="true" default_native="icaltime_null_time()"> <method name="i_cal_time_new" corresponds="CUSTOM" kind="constructor" since="1.0"> @@ -86,7 +78,7 @@ <method name="i_cal_time_get_timezone" corresponds="(void *)icaltime_get_timezone" kind="get" since="1.0"> <parameter type="const ICalTime *" name="tt" annotation="in, transfer none" comment="The #ICalTime to be queried"/> <returns type="ICalTimezone *" annotation="transfer none" translator_argus="(GObject *)tt, TRUE" comment="The timezone information" /> - <comment xml:space="preserve">Returns the timezone.</comment> + <comment xml:space="preserve">Returns the timezone, the #ICalTimezone object is cached and can be either unreferenced once the last instance is used or can be kept until i_cal_object_free_global_objects() is called (usually at the very end of the program).</comment> </method> <method name="i_cal_time_set_timezone" corresponds="icaltime_set_timezone" kind="set" since="1.0"> <parameter type="ICalTime *" name="tt" native_op="POINTER" comment="The #ICalTime"/> @@ -95,7 +87,7 @@ </method> <method name="i_cal_time_get_tzid" corresponds="icaltime_get_tzid" kind="get" since="1.0"> <parameter type="const ICalTime *" name="tt" annotation="in, transfer none" comment="The #ICalTime to be queried"/> - <returns type="const gchar *" annotation="allow-none, transfer none" comment="The tzid of #ICalTime, or NULL if floating type" /> + <returns type="const gchar *" annotation="nullable, transfer none" comment="The tzid of #ICalTime, or NULL if floating type" /> <comment xml:space="preserve">Returns the tzid, or NULL for a floating time.</comment> </method> <method name="i_cal_time_day_of_year" corresponds="icaltime_day_of_year" since="1.0"> @@ -143,7 +135,7 @@ <parameter type="const ICalTime *" name="a" annotation="in, transfer none" comment="The #ICalTime to be compared"/> <parameter type="const ICalTime *" name="b" annotation="in, transfer none" comment="The #ICalTime to be compared"/> <returns type="gint" comment="-1, 0, or 1 to indicate that a less than b, a==b or a larger than b." /> - <comment xml:space="preserve">Returns -1, 0, or 1 to indicate that a less than b, a==b or a larger than b.</comment> + <comment xml:space="preserve">i_cal_time_compare returns an integer indicating the result of the comparison, as follow:</comment> </method> <method name="i_cal_time_compare_date_only" corresponds="icaltime_compare_date_only" since="1.0"> <parameter type="const ICalTime *" name="a" annotation="in, transfer none" comment="The #ICalTime to be compared"/> diff --git a/src/libical-glib/api/i-cal-timezone.xml b/src/libical-glib/api/i-cal-timezone.xml index dfa4140d..0de66874 100644 --- a/src/libical-glib/api/i-cal-timezone.xml +++ b/src/libical-glib/api/i-cal-timezone.xml @@ -1,21 +1,13 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Timezone" native="icaltimezone" is_possible_global="true" destroy_func="i_cal_timezone_destroy"> <method name="i_cal_timezone_new" corresponds="icaltimezone_new" kind="constructor" since="1.0"> - <returns type="ICalTimezone *" annotation="transfer full, allow-none" translator="i_cal_timezone_new_full" translator_argus="NULL, FALSE" comment="The newly created object of the type #ICalTimezone." /> + <returns type="ICalTimezone *" annotation="transfer full, nullable" translator="i_cal_timezone_new_full" translator_argus="NULL, FALSE" comment="The newly created object of the type #ICalTimezone." /> <comment xml:space="preserve">The constructor of the type #ICalTimezone.</comment> </method> <method name="i_cal_timezone_destroy" corresponds="CUSTOM" annotation="skip" kind="private" since="1.0"> diff --git a/src/libical-glib/api/i-cal-trigger.xml b/src/libical-glib/api/i-cal-trigger.xml index 6d3d1ffb..81cc19ec 100644 --- a/src/libical-glib/api/i-cal-trigger.xml +++ b/src/libical-glib/api/i-cal-trigger.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Trigger" native="struct icaltriggertype" is_bare="true" default_native="icaltriggertype_from_int (0)"> <method name="i_cal_trigger_new_from_int" corresponds="icaltriggertype_from_int" kind="constructor" since="1.0"> diff --git a/src/libical-glib/api/i-cal-unknowntokenhandling.xml b/src/libical-glib/api/i-cal-unknowntokenhandling.xml index 5c08c7ba..7d656224 100644 --- a/src/libical-glib/api/i-cal-unknowntokenhandling.xml +++ b/src/libical-glib/api/i-cal-unknowntokenhandling.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Unknowntokenhandling"> <enum name="ICalUnknowntokenhandling" native_name="ical_unknown_token_handling" default_native="0"> diff --git a/src/libical-glib/api/i-cal-value.xml b/src/libical-glib/api/i-cal-value.xml index adfaf2a9..c7cf2c6e 100644 --- a/src/libical-glib/api/i-cal-value.xml +++ b/src/libical-glib/api/i-cal-value.xml @@ -1,17 +1,9 @@ <!-- - Copyright (C) 2015 William Yu <williamyu@gnome.org> + SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> - This library is free software: you can redistribute it and/or modify it - under the terms of version 2.1. of the GNU Lesser General Public License - as published by the Free Software Foundation. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - for more details. - You should have received a copy of the GNU Lesser General Public License - along with this library. If not, see <https://www.gnu.org/licenses/>. --> <structure namespace="ICal" name="Value" native="icalvalue" destroy_func="icalvalue_free" includes="string.h"> <method name="i_cal_value_new" corresponds="icalvalue_new" kind="constructor" since="1.0"> @@ -78,7 +70,7 @@ be cloned."/> </method> <method name="i_cal_value_encode_ical_string" corresponds="CUSTOM" since="1.0"> <parameter type="const gchar *" name="szText" comment="A string"/> - <returns type="gchar *" annotation="allow-none, transfer full" comment="The encoded string. NULL if fail."/> + <returns type="gchar *" annotation="nullable, transfer full" comment="The encoded string. NULL if fail."/> <comment xml:space="preserve">Encodes a character string in ical format, escape certain characters, etc.</comment> <custom> gchar *szEncText; gchar *buffer = NULL; @@ -99,7 +91,7 @@ be cloned."/> </method> <method name="i_cal_value_decode_ical_string" corresponds="CUSTOM" since="1.0"> <parameter type="const gchar *" name="szText" comment="A string"/> - <returns type="gchar *" annotation="allow-none, transfer full" comment="The decoded string. NULL if fail."/> + <returns type="gchar *" annotation="nullable, transfer full" comment="The decoded string. NULL if fail."/> <comment xml:space="preserve">Extracts the original character string encoded by the above function.</comment> <custom> gchar *szDecText; gchar *buffer = NULL; diff --git a/src/libical-glib/i-cal-object.c.in b/src/libical-glib/i-cal-object.c.in index 4b2fa34e..95ab14b4 100644 --- a/src/libical-glib/i-cal-object.c.in +++ b/src/libical-glib/i-cal-object.c.in @@ -1,17 +1,7 @@ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software: you can redistribute it and/or modify it - * under the terms of version 2.1. of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifdef HAVE_CONFIG_H @@ -107,6 +97,7 @@ typedef struct gpointer native; GDestroyNotify native_destroy_func; gboolean is_global_memory; + gboolean always_destroy; GObject *owner; GSList *dependers; /* referenced GObject-s */ } ICalObjectPrivate; @@ -122,6 +113,7 @@ enum PROP_NATIVE, PROP_NATIVE_DESTROY_FUNC, PROP_IS_GLOBAL_MEMORY, + PROP_ALWAYS_DESTROY, PROP_OWNER }; @@ -149,6 +141,10 @@ static void i_cal_object_set_property(GObject *object, guint property_id, priv->is_global_memory = g_value_get_boolean(value); return; + case PROP_ALWAYS_DESTROY: + i_cal_object_set_always_destroy(iobject, g_value_get_boolean(value)); + return; + case PROP_OWNER: i_cal_object_set_owner(iobject, g_value_get_object(value)); return; @@ -177,6 +173,10 @@ static void i_cal_object_get_property(GObject *object, guint property_id, g_value_set_boolean(value, i_cal_object_get_is_global_memory(iobject)); return; + case PROP_ALWAYS_DESTROY: + g_value_set_boolean(value, i_cal_object_get_always_destroy(iobject)); + return; + case PROP_OWNER: g_value_take_object(value, i_cal_object_ref_owner(iobject)); return; @@ -190,7 +190,8 @@ static void i_cal_object_finalize(GObject *object) ICalObject *iobject = I_CAL_OBJECT(object); ICalObjectPrivate *priv = i_cal_object_get_instance_private(iobject); - if (!priv->owner && !priv->is_global_memory && + if ((priv->always_destroy || !priv->owner) && + !priv->is_global_memory && priv->native && priv->native_destroy_func) { g_clear_pointer(&priv->native, priv->native_destroy_func); } @@ -264,6 +265,25 @@ static void i_cal_object_class_init(ICalObjectClass * class) G_PARAM_STATIC_STRINGS)); /** + * ICalObject:always-destroy: + * + * Whether free the native libical structure on #ICalObject's finalize even + * if the object has set an owner. + * + * Since: 3.0.11 + **/ + g_object_class_install_property( + object_class, + PROP_ALWAYS_DESTROY, + g_param_spec_boolean( + "always-destroy", + "Always-Destroy", + "Whether the native libical structure is freed even when the owner is set", + FALSE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + /** * ICalObject:owner: * * Owner of the native libical structure. If set, then it is @@ -294,7 +314,7 @@ static void i_cal_object_init(ICalObject *iobject) * @native: a native libical structure * @native_destroy_func: a function to be called on @native when it should be freed * @is_global_memory: whether @native is a global shared memory structure - * @owner: (allow-none): an owner of @native + * @owner: (nullable): an owner of @native * * Creates an #ICalObject descendant of type @type and initialize private members * of it. The descendants should call this function in their _new() function, or use @@ -556,8 +576,8 @@ void i_cal_object_set_owner(ICalObject *iobject, GObject *owner) * if not NULL, is referenced for thread safety. Unref it with g_object_unref * when done with it. * - * Returns: (transfer full) (allow-none): Current owner of the libical - * native structure. returns NULL, when there is no owner. + * Returns: (transfer full) (nullable): Current owner of the libical + * native structure. Returns %NULL when there is no owner. * * Since: 1.0 **/ @@ -663,3 +683,58 @@ void i_cal_object_remove_depender(ICalObject *iobject, GObject *depender) UNLOCK_PROPS(priv); } + +/** + * i_cal_object_set_always_destroy: + * @iobject: an #ICalObject + * @value: value to set + * + * Sets the @ICalObject::always-destroy property value. When %TRUE, the native + * libical structure is always freed, even when an owner of the @iobject is set. + * + * Since: 3.0.11 + **/ +void i_cal_object_set_always_destroy(ICalObject *iobject, gboolean value) +{ + ICalObjectPrivate *priv = i_cal_object_get_instance_private(iobject); + gboolean changed; + + g_return_if_fail(I_CAL_IS_OBJECT(iobject)); + + LOCK_PROPS(priv); + + changed = (value ? 1 : 0) != (priv->always_destroy ? 1 : 0); + if (changed) + priv->always_destroy = value; + + UNLOCK_PROPS(priv); + + if (changed) + g_object_notify(G_OBJECT(iobject), "always-destroy"); +} + +/** + * i_cal_object_get_always_destroy: + * @iobject: an #ICalObject + * + * Obtain the @ICalObject::always-destroy property value. + * + * Returns: Whether the native libical structure is freed even when an owner is set. + * + * Since: 3.0.11 + **/ +gboolean i_cal_object_get_always_destroy(ICalObject *iobject) +{ + ICalObjectPrivate *priv = i_cal_object_get_instance_private(iobject); + gboolean value; + + g_return_val_if_fail(I_CAL_IS_OBJECT(iobject), FALSE); + + LOCK_PROPS(priv); + + value = priv->always_destroy; + + UNLOCK_PROPS(priv); + + return value; +} diff --git a/src/libical-glib/i-cal-object.h.in b/src/libical-glib/i-cal-object.h.in index 799e3112..9803b5c2 100644 --- a/src/libical-glib/i-cal-object.h.in +++ b/src/libical-glib/i-cal-object.h.in @@ -1,17 +1,7 @@ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software: you can redistribute it and/or modify it - * under the terms of version 2.1. of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #if !defined (__LIBICAL_GLIB_H_INSIDE__) && !defined (LIBICAL_GLIB_COMPILATION) @@ -77,6 +67,10 @@ LIBICAL_ICAL_EXPORT void i_cal_object_add_depender(ICalObject *iobject, GObject LIBICAL_ICAL_EXPORT void i_cal_object_remove_depender(ICalObject *iobject, GObject *depender); +LIBICAL_ICAL_EXPORT void i_cal_object_set_always_destroy(ICalObject *iobject, gboolean value); + +LIBICAL_ICAL_EXPORT gboolean i_cal_object_get_always_destroy(ICalObject *iobject); + LIBICAL_ICAL_EXPORT void i_cal_object_free_global_objects(void); G_END_DECLS diff --git a/src/libical-glib/libical-glib.pc.in b/src/libical-glib/libical-glib.pc.in index e164cfb5..8938834f 100644 --- a/src/libical-glib/libical-glib.pc.in +++ b/src/libical-glib/libical-glib.pc.in @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright Contributors to the libical project +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ diff --git a/src/libical-glib/tools/generator.c b/src/libical-glib/tools/generator.c index 609c9297..d1d3fc23 100644 --- a/src/libical-glib/tools/generator.c +++ b/src/libical-glib/tools/generator.c @@ -1,16 +1,7 @@ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #include "generator.h" @@ -1575,13 +1566,39 @@ gchar *get_translator_for_return(Ret *ret) return res; } +static gboolean parameter_is_out(Parameter *para) +{ + GList *link; + for (link = para->annotations; link; link = g_list_next(link)) { + if (g_strcmp0(link->data, "out") == 0 || + g_strcmp0(link->data, "inout") == 0 || + g_str_has_prefix(link->data, "out ")) { + break; + } + } + + return link != NULL; +} + static gboolean annotation_contains_nullable(GList *annotations) /* gchar * */ { GList *link; for (link = annotations; link; link = g_list_next(link)) { - if (g_strcmp0(link->data, "allow-none") == 0 || - g_strcmp0(link->data, "nullable") == 0) { + if (g_strcmp0(link->data, "nullable") == 0) { + break; + } + } + + return link != NULL; +} + +static gboolean annotation_contains_optional(GList *annotations) /* gchar * */ +{ + GList *link; + + for (link = annotations; link; link = g_list_next(link)) { + if (g_strcmp0(link->data, "optional") == 0) { break; } } @@ -2033,6 +2050,7 @@ gchar *get_source_run_time_checkers(Method *method, const gchar *namespace) gchar *defaultValue; gchar *retTrueType; guint namespace_len; + gboolean param_is_out; g_return_val_if_fail(method != NULL, NULL); g_return_val_if_fail(namespace != NULL && *namespace != '\0', NULL); @@ -2095,7 +2113,10 @@ gchar *get_source_run_time_checkers(Method *method, const gchar *namespace) (void)g_stpcpy(buffer + strlen(buffer), "\n"); } - if (i != namespace_len && !annotation_contains_nullable(parameter->annotations)) { + param_is_out = parameter_is_out(parameter); + if (i != namespace_len && ( + (!param_is_out && !annotation_contains_nullable(parameter->annotations)) || + (param_is_out && !annotation_contains_optional(parameter->annotations)))) { (void)g_stpcpy(buffer + strlen(buffer), "\t"); if (method->ret != NULL) { (void)g_stpcpy(buffer + strlen(buffer), "g_return_val_if_fail ("); diff --git a/src/libical-glib/tools/generator.h b/src/libical-glib/tools/generator.h index 4aa14693..31a4ea35 100644 --- a/src/libical-glib/tools/generator.h +++ b/src/libical-glib/tools/generator.h @@ -1,16 +1,7 @@ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifndef GENERATOR_H diff --git a/src/libical-glib/tools/header-forward-declarations-template b/src/libical-glib/tools/header-forward-declarations-template index 7ea06c29..95de7492 100644 --- a/src/libical-glib/tools/header-forward-declarations-template +++ b/src/libical-glib/tools/header-forward-declarations-template @@ -1,19 +1,9 @@ /* Generated file (by generator) */ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software: you can redistribute it and/or modify it - * under the terms of version 2.1. of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #if !defined (__LIBICAL_GLIB_H_INSIDE__) && !defined (LIBICAL_GLIB_COMPILATION) diff --git a/src/libical-glib/tools/header-header-template b/src/libical-glib/tools/header-header-template index 9dde6369..b19012c2 100644 --- a/src/libical-glib/tools/header-header-template +++ b/src/libical-glib/tools/header-header-template @@ -1,19 +1,9 @@ /* Generated file (by generator) */ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software: you can redistribute it and/or modify it - * under the terms of version 2.1. of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifndef LIBICAL_GLIB_H @@ -21,10 +11,6 @@ #include <glib-object.h> -#if !defined(LIBICAL_GLIB_UNSTABLE_API) && !defined(LIBICAL_GLIB_COMPILATION) -#error "Define LIBICAL_GLIB_UNSTABLE_API, to indicate it's understood the libical-glib API is currently unstable" -#endif - #define __LIBICAL_GLIB_H_INSIDE__ #include <libical-glib/i-cal-forward-declarations.h> diff --git a/src/libical-glib/tools/header-template b/src/libical-glib/tools/header-template index f4edf16f..a51c7331 100644 --- a/src/libical-glib/tools/header-template +++ b/src/libical-glib/tools/header-template @@ -1,19 +1,9 @@ /* Generated file (by generator) */ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software: you can redistribute it and/or modify it - * under the terms of version 2.1. of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #if !defined (__LIBICAL_GLIB_H_INSIDE__) && !defined (LIBICAL_GLIB_COMPILATION) diff --git a/src/libical-glib/tools/source-template b/src/libical-glib/tools/source-template index 8b71354e..4a354b2c 100644 --- a/src/libical-glib/tools/source-template +++ b/src/libical-glib/tools/source-template @@ -1,19 +1,9 @@ /* Generated file (by generator) */ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software: you can redistribute it and/or modify it - * under the terms of version 2.1. of the GNU Lesser General Public License - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see <https://www.gnu.org/licenses/>. + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifdef HAVE_CONFIG_H diff --git a/src/libical-glib/tools/xml-parser.c b/src/libical-glib/tools/xml-parser.c index a9cf2704..76e39b7f 100644 --- a/src/libical-glib/tools/xml-parser.c +++ b/src/libical-glib/tools/xml-parser.c @@ -1,16 +1,7 @@ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #include "xml-parser.h" diff --git a/src/libical-glib/tools/xml-parser.h b/src/libical-glib/tools/xml-parser.h index bccbb4d3..403c40c0 100644 --- a/src/libical-glib/tools/xml-parser.h +++ b/src/libical-glib/tools/xml-parser.h @@ -1,16 +1,8 @@ /* - * Copyright (C) 2015 William Yu <williamyu@gnome.org> + * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ */ #ifndef XML_PARSER_H diff --git a/src/libical/CMakeLists.txt b/src/libical/CMakeLists.txt index 9c7266b4..f53413a1 100644 --- a/src/libical/CMakeLists.txt +++ b/src/libical/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + add_definitions(-Dlibical_ical_EXPORTS) configure_file( @@ -6,12 +9,20 @@ configure_file( @ONLY ) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/icaltime.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/icaltime.h +) + include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) +if(LIBICAL_DEVMODE_MEMORY_CONSISTENCY) + include_directories(${CMAKE_SOURCE_DIR}/src/test) +endif() if(ICU_FOUND) include_directories(${ICU_INCLUDE_DIRS}) @@ -42,6 +53,7 @@ add_custom_command( DEPENDS ${PROPERTYDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalderivedproperty.h.in + COMMENT "Generate icalderivedproperty.h" ) list(APPEND BUILT_HEADERS ${CMAKE_BINARY_DIR}/src/libical/icalderivedproperty.h) @@ -57,6 +69,7 @@ add_custom_command( DEPENDS ${PROPERTYDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalderivedproperty.c.in + COMMENT "Generate icalderivedproperty.c" ) list(APPEND BUILT_SOURCES ${CMAKE_BINARY_DIR}/src/libical/icalderivedproperty.c) @@ -76,6 +89,7 @@ add_custom_command( DEPENDS ${PARAMETERDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalderivedparameter.h.in + COMMENT "Generate icalderivedparameter.h" ) list(APPEND BUILT_HEADERS ${CMAKE_BINARY_DIR}/src/libical/icalderivedparameter.h) @@ -90,6 +104,7 @@ add_custom_command( DEPENDS ${PARAMETERDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalderivedparameter.c.in + COMMENT "Generate icalderivedparameter.c" ) list(APPEND BUILT_SOURCES ${CMAKE_BINARY_DIR}/src/libical/icalderivedparameter.c) @@ -109,6 +124,7 @@ add_custom_command( DEPENDS ${RESTRICTIONDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalrestriction.c.in + COMMENT "Generate icalrestriction.c" ) list(APPEND BUILT_SOURCES ${CMAKE_BINARY_DIR}/src/libical/icalrestriction.c) @@ -128,6 +144,7 @@ add_custom_command( DEPENDS ${VALUEDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalderivedvalue.h.in + COMMENT "Generate icalderivedvalue.h" ) list(APPEND BUILT_HEADERS ${CMAKE_BINARY_DIR}/src/libical/icalderivedvalue.h) @@ -142,6 +159,7 @@ add_custom_command( DEPENDS ${VALUEDEPS} ${CMAKE_SOURCE_DIR}/src/libical/icalderivedvalue.c.in + COMMENT "Generate icalderivedvalue.c" ) list(APPEND BUILT_SOURCES ${CMAKE_BINARY_DIR}/src/libical/icalderivedvalue.c) @@ -156,6 +174,7 @@ endif() add_custom_target( ical-header ALL DEPENDS ${CMAKE_BINARY_DIR}/src/libical/ical.h + COMMENT "Target to generate the aggregate ical.h header" ) # GObject Introspection @@ -243,6 +262,9 @@ set(ical_LIB_SRCS caldate.c astime.h ) +if(LIBICAL_DEVMODE_MEMORY_CONSISTENCY) + list(APPEND ical_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/test/test-malloc.c) +endif() add_custom_command( OUTPUT @@ -254,6 +276,7 @@ add_custom_command( -DICAL_FILE_H_FILE:FILEPATH=${CMAKE_BINARY_DIR}/src/libical/ical.h -P ${CMAKE_CURRENT_SOURCE_DIR}/ical_file.cmake DEPENDS ${ical_LIB_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/ical_file.cmake + COMMENT "Generate the aggregate ical.h header" ) add_library(ical ${LIBRARY_TYPE} ${ical_LIB_SRCS}) @@ -265,8 +288,11 @@ elseif(STATIC_ONLY) add_library(ical-static ALIAS ical) endif() -target_link_libraries(ical ${CMAKE_THREAD_LIBS_INIT}) +target_include_directories(ical INTERFACE "$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>") +if(DEFINED CMAKE_THREAD_LIBS_INIT) + target_link_libraries(ical ${CMAKE_THREAD_LIBS_INIT}) +endif() if(ICU_FOUND) target_link_libraries(ical ${ICU_LIBRARIES}) endif() @@ -332,7 +358,10 @@ if(WITH_CXX_BINDINGS) elseif(STATIC_ONLY) add_library(ical_cxx-static ALIAS ical_cxx) endif() - target_link_libraries(ical_cxx ical ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(ical_cxx ical) + if(DEFINED CMAKE_THREAD_LIBS_INIT) + target_link_libraries(ical_cxx ${CMAKE_THREAD_LIBS_INIT}) + endif() if(MSVC) set_target_properties(ical_cxx PROPERTIES PREFIX "lib") @@ -393,7 +422,7 @@ install(FILES icalproperty.h icalrecur.h icalrestriction.h - icaltime.h + ${CMAKE_BINARY_DIR}/src/libical/icaltime.h icaltz-util.h icaltimezone.h icaltypes.h diff --git a/src/libical/astime.h b/src/libical/astime.h index 8c537b0a..f89ddf67 100644 --- a/src/libical/astime.h +++ b/src/libical/astime.h @@ -44,19 +44,10 @@ */ /*====================================================================== - (C) COPYRIGHT 2018, Markus Minichmayr + SPDX-FileCopyrightText: 2018, Markus Minichmayr https://tapkey.com - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ========================================================================*/ /** diff --git a/src/libical/caldate.c b/src/libical/caldate.c index c62a1aa8..a04bc8b1 100644 --- a/src/libical/caldate.c +++ b/src/libical/caldate.c @@ -3,7 +3,7 @@ * needs of the libical project. The original copyright notice is as follows: */ /* - * Copyright (c) 1986-2000, Hiram Clawson + * Copyright (c) 1986-2000, Hiram Clawson * All rights reserved. * * Redistribution and use in source and binary forms, with or @@ -22,7 +22,7 @@ * Neither name of The Museum of Hiram nor the names of * its contributors may be used to endorse or promote products * derived from this software without specific prior - * written permission. + * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, @@ -35,7 +35,7 @@ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. + * THE POSSIBILITY OF SUCH DAMAGE. */ /* * The modifications made are licensed as follows (to distinguish between @@ -44,22 +44,12 @@ */ /*====================================================================== - (C) COPYRIGHT 2018, Markus Minichmayr + SPDX-FileCopyrightText: 2018, Markus Minichmayr https://tapkey.com - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ========================================================================*/ - #include "astime.h" /* time structures */ /** diff --git a/src/libical/ical_file.cmake b/src/libical/ical_file.cmake index e1db0cc8..59e96d77 100644 --- a/src/libical/ical_file.cmake +++ b/src/libical/ical_file.cmake @@ -1,8 +1,11 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + # ORDERING OF HEADERS IS SIGNIFICANT. Don't change this ordering. # It is required to make the combined header ical.h properly. set(COMBINEDHEADERSICAL ${TOPB}/src/libical/icalversion.h - ${TOPS}/src/libical/icaltime.h + ${TOPB}/src/libical/icaltime.h ${TOPS}/src/libical/icalduration.h ${TOPS}/src/libical/icalperiod.h ${TOPS}/src/libical/icalenums.h diff --git a/src/libical/icalarray.c b/src/libical/icalarray.c index 58c545d2..a472c3a0 100644 --- a/src/libical/icalarray.c +++ b/src/libical/icalarray.c @@ -2,18 +2,10 @@ FILE: icalarray.c CREATOR: Damon Chaplin 07 March 2001 - (C) COPYRIGHT 2001, Ximian, Inc. + SPDX-FileCopyrightText: 2001, Ximian, Inc. - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -22,6 +14,7 @@ #include "icalarray.h" #include "icalerror.h" +#include "icalmemory.h" #include "qsort_gen.h" #include <stdlib.h> @@ -33,7 +26,7 @@ icalarray *icalarray_new(size_t element_size, size_t increment_size) { icalarray *array; - array = (icalarray *) malloc(sizeof(icalarray)); + array = (icalarray *) icalmemory_new_buffer(sizeof(icalarray)); if (!array) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return NULL; @@ -50,7 +43,7 @@ icalarray *icalarray_new(size_t element_size, size_t increment_size) static void *icalarray_alloc_chunk(icalarray *array) { - void *chunk = malloc(array->element_size * array->increment_size); + void *chunk = icalmemory_new_buffer(array->element_size * array->increment_size); if (!chunk) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); @@ -68,23 +61,30 @@ icalarray *icalarray_copy(icalarray *originalarray) return NULL; } - array->num_elements = originalarray->num_elements; - array->space_allocated = originalarray->space_allocated; - - array->chunks = malloc(chunks * sizeof(void *)); + array->chunks = icalmemory_new_buffer(chunks * sizeof(void *)); if (array->chunks) { for (chunk = 0; chunk < chunks; chunk++) { array->chunks[chunk] = icalarray_alloc_chunk(array); if (array->chunks[chunk]) { memcpy(array->chunks[chunk], originalarray->chunks[chunk], array->increment_size * array->element_size); + + array->space_allocated += array->increment_size; + } else { + icalerror_set_errno(ICAL_ALLOCATION_ERROR); + icalarray_free(array); + return NULL; } } } else { icalerror_set_errno(ICAL_ALLOCATION_ERROR); + icalarray_free(array); + return NULL; } + array->num_elements = originalarray->num_elements; + return array; } @@ -95,12 +95,12 @@ void icalarray_free(icalarray *array) size_t chunk; for (chunk = 0; chunk < chunks; chunk++) { - free(array->chunks[chunk]); + icalmemory_free_buffer(array->chunks[chunk]); } - free(array->chunks); + icalmemory_free_buffer(array->chunks); array->chunks = 0; } - free(array); + icalmemory_free_buffer(array); } void icalarray_append(icalarray *array, const void *element) @@ -109,6 +109,10 @@ void icalarray_append(icalarray *array, const void *element) if (array->num_elements >= array->space_allocated) { icalarray_expand(array, 1); + if (array->num_elements >= array->space_allocated) { + /* expansion failed. Error has already been set. */ + return; + } } pos = array->num_elements++; @@ -180,7 +184,7 @@ static void icalarray_expand(icalarray *array, size_t space_needed) num_new_chunks = 1; } - new_chunks = malloc((num_chunks + num_new_chunks) * sizeof(void *)); + new_chunks = icalmemory_new_buffer((num_chunks + num_new_chunks) * sizeof(void *)); if (new_chunks) { if (array->chunks && num_chunks) { @@ -188,9 +192,13 @@ static void icalarray_expand(icalarray *array, size_t space_needed) } for (c = 0; c < num_new_chunks; c++) { new_chunks[c + num_chunks] = icalarray_alloc_chunk(array); + if (!new_chunks[c + num_chunks]) { + num_new_chunks = c; + break; + } } if (array->chunks) { - free(array->chunks); + icalmemory_free_buffer(array->chunks); } array->chunks = new_chunks; array->space_allocated = array->space_allocated + num_new_chunks * array->increment_size; diff --git a/src/libical/icalarray.h b/src/libical/icalarray.h index 2fc9fb26..4c253fbc 100644 --- a/src/libical/icalarray.h +++ b/src/libical/icalarray.h @@ -2,18 +2,10 @@ FILE: icalarray.h CREATOR: Damon Chaplin 07 March 2001 - (C) COPYRIGHT 2001, Ximian, Inc. + SPDX-FileCopyrightText: 2001, Ximian, Inc. - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /** @file icalarray.h @@ -27,6 +19,8 @@ #include "libical_ical_export.h" +#include <stddef.h> + /** * @typedef icalarray * @brief A struct representing an icalarray object @@ -42,29 +36,29 @@ struct _icalarray }; /** - * @brief Creates a new ::icalarray object. + * @brief Creates a new icalarray object. * @param element_size The size of the elements to be held by the array * @param increment_size How many extra elements worth of space to allocate on expansion - * @return The new ::icalarray object + * @return The new icalarray object * @sa icalarray_free() * - * Creates a new ::icalarray object. The parameter @a element_size determines + * Creates a new icalarray object. The parameter @a element_size determines * the size of the elements that the array will hold (in bytes). The parameter * @a increment_size determines how many extra elements to be allocated when * expanding the array for performance reasons (expansions are expensive, since * it involves copying all existing elements). * * @par Error handling - * If @a element_size or @a increment_size is not at least 1, using the ::icalarray + * If @a element_size or @a increment_size is not at least 1, using the icalarray * object results in undefined behaviour. If there is an error while creating the * object, it returns `NULL` and sets ::icalerrno to ::ICAL_NEWFAILED_ERROR. * * @par Ownership - * The returned ::icalarray object is owned by the caller of the function, + * The returned icalarray object is owned by the caller of the function, * and needs to be released properly after it's no longer needed with * icalarray_free(). * - * ### Usage + * @par Usage * ```c * // create new array * icalarray *array = icalarray_new(sizeof(int), 1); @@ -81,11 +75,11 @@ struct _icalarray LIBICAL_ICAL_EXPORT icalarray *icalarray_new(size_t element_size, size_t increment_size); /** - * @brief Copies an existing ::icalarray and its elements, creating a new one. + * @brief Copies an existing icalarray and its elements, creating a new one. * @param array The array to copy * @return A new array, holding all the elements of @a array * - * Creates a new ::icalarray object, copying all the existing elements from + * Creates a new icalarray object, copying all the existing elements from * @a array as well as its properties (such as @a element_size and * @a increment_size) over. * @@ -98,7 +92,7 @@ LIBICAL_ICAL_EXPORT icalarray *icalarray_new(size_t element_size, size_t increme * The created copy is owned by the caller of the function, and needs to * be released with icalarray_free() after it's no longer being used. * - * ### Usage + * @par Usage * ```c * // create new array * icalarray *array = icalarray_new(sizeof(int), 1); @@ -122,7 +116,7 @@ LIBICAL_ICAL_EXPORT icalarray *icalarray_copy(icalarray *array); * @brief Frees an array object and everything that it contains. * @param array The array to release * - * ### Example + * @par Example * ```c * // creating an array * icalarray *array = icalarray_new(sizeof(int), 1); @@ -149,7 +143,7 @@ LIBICAL_ICAL_EXPORT void icalarray_free(icalarray *array); * The @a element does not get consumed by the method, since it creates * a copy of it * - * ### Usage + * @par Usage * ```c * // create new array * icalarray *array = icalarray_new(sizeof(int), 1); @@ -176,7 +170,7 @@ LIBICAL_ICAL_EXPORT void icalarray_append(icalarray *array, const void *element) * If the array is empty, using this function results in undefined behaviour. * If the @a position is non-existent, it removes the last element. * - * ### Usage + * @par Usage * ```c * // create new array * icalarray *array = icalarray_new(sizeof(int), 2); @@ -227,10 +221,10 @@ LIBICAL_ICAL_EXPORT void icalarray_remove_element_at(icalarray *array, size_t po * results in undefined behaviour. * * @par Ownership - * The element is owned by the ::icalarray, it must not be freed by + * The element is owned by the icalarray, it must not be freed by * the user. * - * ### Usage + * @par Usage * ```c * // create new array * icalarray *array = icalarray_new(sizeof(int), 1); @@ -255,7 +249,7 @@ LIBICAL_ICAL_EXPORT void icalarray_remove_element_at(icalarray *array, size_t po LIBICAL_ICAL_EXPORT void *icalarray_element_at(icalarray *array, size_t position); /** - * @brief Sorts the elements of an ::icalarray using the given comparison function. + * @brief Sorts the elements of an icalarray using the given comparison function. * @param array The array to sort * @param compare The comparison function to use * @@ -263,7 +257,7 @@ LIBICAL_ICAL_EXPORT void *icalarray_element_at(icalarray *array, size_t position * Passing `NULL` as either @a array or @a compare results in undefined * behaviour. * - * ### Usage + * @par Usage * ```c * int compare_ints(const void *a, const void *b) { * return *((int*)a) - *((int*)b); diff --git a/src/libical/icalattach.c b/src/libical/icalattach.c index 423cc27e..a2ec5fce 100644 --- a/src/libical/icalattach.c +++ b/src/libical/icalattach.c @@ -2,18 +2,10 @@ FILE: icalattach.c CREATOR: acampi 28 May 02 - (C) COPYRIGHT 2002, Andrea Campi <a.campi@inet.it> + SPDX-FileCopyrightText: 2002, Andrea Campi <a.campi@inet.it> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -22,6 +14,7 @@ #include "icalattachimpl.h" #include "icalerror.h" +#include "icalmemory.h" #include <errno.h> #include <stdlib.h> @@ -33,13 +26,13 @@ icalattach *icalattach_new_from_url(const char *url) icalerror_check_arg_rz((url != NULL), "url"); - if ((attach = malloc(sizeof(icalattach))) == NULL) { + if ((attach = icalmemory_new_buffer(sizeof(icalattach))) == NULL) { errno = ENOMEM; return NULL; } - if ((url_copy = strdup(url)) == NULL) { - free(attach); + if ((url_copy = icalmemory_strdup(url)) == NULL) { + icalmemory_free_buffer(attach); errno = ENOMEM; return NULL; } @@ -54,7 +47,7 @@ icalattach *icalattach_new_from_url(const char *url) static void attach_data_free(char *data, void *free_fn_data) { _unused(free_fn_data); - free(data); + icalmemory_free_buffer(data); } icalattach *icalattach_new_from_data(const char *data, icalattach_free_fn_t free_fn, @@ -64,15 +57,15 @@ icalattach *icalattach_new_from_data(const char *data, icalattach_free_fn_t free icalerror_check_arg_rz((data != NULL), "data"); - if ((attach = malloc(sizeof(icalattach))) == NULL) { + if ((attach = icalmemory_new_buffer(sizeof(icalattach))) == NULL) { errno = ENOMEM; return NULL; } if (!free_fn) { - data = strdup(data); + data = icalmemory_strdup(data); if (!data) { - free(attach); + icalmemory_free_buffer(attach); errno = ENOMEM; return NULL; } @@ -107,12 +100,12 @@ void icalattach_unref(icalattach *attach) return; if (attach->is_url) { - free(attach->u.url.url); + icalmemory_free_buffer(attach->u.url.url); } else if (attach->u.data.free_fn) { (* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data); } - free(attach); + icalmemory_free_buffer(attach); } int icalattach_get_is_url(icalattach *attach) diff --git a/src/libical/icalattach.h b/src/libical/icalattach.h index 9a606773..b21aaf50 100644 --- a/src/libical/icalattach.h +++ b/src/libical/icalattach.h @@ -2,18 +2,10 @@ FILE: icalattach.h CREATOR: acampi 28 May 02 - (C) COPYRIGHT 2002, Andrea Campi <a.campi@inet.it> + SPDX-FileCopyrightText: 2002, Andrea Campi <a.campi@inet.it> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /** @@ -23,7 +15,7 @@ * With the `ATTACH` property, the iCal standard defines a way to * associate a document object with a calendar component. * - * These are represented with ::icalattach objects in libical. + * These are represented with icalattach objects in libical. * This file contains functions to create and work with these * objects. */ @@ -37,7 +29,7 @@ * @typedef icalattach * @brief An iCal attach object representing a link to a document object. * - * Represents an association with a document object. ::icalattach objects + * Represents an association with a document object. icalattach objects * are reference counted, meaning that if the last reference to them is * removed (with icalattach_unref()), they are destroyed. */ @@ -54,9 +46,9 @@ typedef struct icalattach_impl icalattach; typedef void (*icalattach_free_fn_t) (char *data, void *user_data); /** - * @brief Creates new ::icalattach object from a URL. + * @brief Creates new icalattach object from a URL. * @param url The URL to create the object from - * @return An ::icalattach object with the given URL as association + * @return An icalattach object with the given URL as association * @sa icalattach_unref() * * @par Error handling @@ -65,12 +57,12 @@ typedef void (*icalattach_free_fn_t) (char *data, void *user_data); * returns `NULL` and sets `errno` to `ENOMEM`. * * @par Ownership - * The returned ::icalattach object is owned by the caller of the function. - * ::icalattach objects are reference counted, which means that after + * The returned icalattach object is owned by the caller of the function. + * icalattach objects are reference counted, which means that after * use, icalattach_unref() needs to be called to signal that they are * not used anymore. * - * ### Usage + * @par Usage * ```c * // creates new * icalattach *attach = icalattach_new_from_url("http://example.com"); @@ -86,11 +78,11 @@ typedef void (*icalattach_free_fn_t) (char *data, void *user_data); LIBICAL_ICAL_EXPORT icalattach *icalattach_new_from_url(const char *url); /** - * @brief Creates new ::icalattach object from data. - * @param data The data to create the ::icalattach from + * @brief Creates new icalattach object from data. + * @param data The data to create the icalattach from * @param free_fn The function to free the data * @param free_fn_data Data to pass to the @a free_fn - * @return An ::icalattach object with the given data + * @return An icalattach object with the given data * @sa icalattach_unref() * * @par Error handling @@ -99,8 +91,8 @@ LIBICAL_ICAL_EXPORT icalattach *icalattach_new_from_url(const char *url); * returns `NULL` and sets `errno` to `ENOMEM`. * * @par Ownership - * The returned ::icalattach object is owned by the caller of the function. - * ::icalattach objects are reference counted, which means that after + * The returned icalattach object is owned by the caller of the function. + * icalattach objects are reference counted, which means that after * use, icalattach_unref() needs to be called to signal that they are * not used anymore. */ @@ -109,7 +101,7 @@ LIBICAL_ICAL_EXPORT icalattach *icalattach_new_from_data(const char *data, void *free_fn_data); /** - * @brief Increments reference count of the ::icalattach. + * @brief Increments reference count of the icalattach. * @param attach The object to increase the reference count of * @sa icalattach_unref() * @@ -125,7 +117,7 @@ LIBICAL_ICAL_EXPORT icalattach *icalattach_new_from_data(const char *data, LIBICAL_ICAL_EXPORT void icalattach_ref(icalattach *attach); /** - * @brief Decrements reference count of the ::icalattach. + * @brief Decrements reference count of the icalattach. * @param attach The object to decrease the reference count of * @sa icalattach_ref() * @@ -140,7 +132,7 @@ LIBICAL_ICAL_EXPORT void icalattach_ref(icalattach *attach); * Calling this function releases the icalattach back to the library, * and it must not be used afterwards. * - * ### Usage + * @par Usage * ```c * // creates new * icalattach *attach = icalattach_new_from_url("http://example.com"); @@ -153,7 +145,7 @@ LIBICAL_ICAL_EXPORT void icalattach_unref(icalattach *attach); /** * @brief Determines if @a attach is an URL. - * @param attach the ::icalattach object to check + * @param attach the icalattach object to check * @return 1 if it is a URL, otherwise 0. * @sa icalattach_get_url() * @@ -161,7 +153,7 @@ LIBICAL_ICAL_EXPORT void icalattach_unref(icalattach *attach); * Returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR if * @a attach is `NULL`. * - * ### Usage + * @par Usage * ```c * // creates new * icalattach *attach = icalattach_new_from_url("http://example.com"); @@ -176,12 +168,12 @@ LIBICAL_ICAL_EXPORT void icalattach_unref(icalattach *attach); LIBICAL_ICAL_EXPORT int icalattach_get_is_url(icalattach *attach); /** - * @brief Returns the URL of the ::icalattach object. + * @brief Returns the URL of the icalattach object. * @param attach The object from which to return the URL * @return The URL of the object * @sa icalattach_get_is_url() * - * Returns the URL of the ::icalattach object. + * Returns the URL of the icalattach object. * * @par Error handling * Returns `NULL` and set ::icalerrno to ::ICAL_BADARG_ERROR if @@ -192,7 +184,7 @@ LIBICAL_ICAL_EXPORT int icalattach_get_is_url(icalattach *attach); * The string returned is owned by libical and must not be freed * by the caller. * - * # Usage + * @par Usage * ```c * // creates new * icalattach *attach = icalattach_new_from_url("http://example.com"); @@ -208,12 +200,12 @@ LIBICAL_ICAL_EXPORT int icalattach_get_is_url(icalattach *attach); LIBICAL_ICAL_EXPORT const char *icalattach_get_url(icalattach *attach); /** - * @brief Returns the data of the ::icalattach object. + * @brief Returns the data of the icalattach object. * @param attach The object from which to return the data * @return The data of the object * @sa icalattach_get_is_url() * - * Returns the URL of the ::icalattach object. + * Returns the URL of the icalattach object. * * @par Error handling * Returns `NULL` and set ::icalerrno to ::ICAL_BADARG_ERROR if diff --git a/src/libical/icalattachimpl.h b/src/libical/icalattachimpl.h index af9975c0..7ca14441 100644 --- a/src/libical/icalattachimpl.h +++ b/src/libical/icalattachimpl.h @@ -2,18 +2,10 @@ FILE: icalattachimpl.h CREATOR: acampi 28 May 02 - (C) COPYRIGHT 2000, Andrea Campi <a.campi@inet.it> + SPDX-FileCopyrightText: 2000, Andrea Campi <a.campi@inet.it> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALATTACHIMPL_H diff --git a/src/libical/icalcomponent.c b/src/libical/icalcomponent.c index deb2c402..4f9fa79d 100644 --- a/src/libical/icalcomponent.c +++ b/src/libical/icalcomponent.c @@ -2,18 +2,10 @@ FILE: icalcomponent.c CREATOR: eric 28 April 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -73,7 +65,7 @@ void icalcomponent_add_children(icalcomponent *impl, va_list args) while ((vp = va_arg(args, void *)) != 0) { - assert(icalcomponent_isa_component(vp) != 0 || icalproperty_isa_property(vp) != 0); + icalassert(icalcomponent_isa_component(vp) != 0 || icalproperty_isa_property(vp) != 0); if (icalcomponent_isa_component(vp) != 0) { icalcomponent_add_component(impl, (icalcomponent *) vp); @@ -91,7 +83,7 @@ static icalcomponent *icalcomponent_new_impl(icalcomponent_kind kind) if (!icalcomponent_kind_is_valid(kind)) return NULL; - if ((comp = (icalcomponent *) malloc(sizeof(icalcomponent))) == 0) { + if ((comp = (icalcomponent *) icalmemory_new_buffer(sizeof(icalcomponent))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -210,7 +202,7 @@ void icalcomponent_free(icalcomponent *c) pvl_free(c->components); if (c->x_name != 0) { - free(c->x_name); + icalmemory_free_buffer(c->x_name); } if (c->timezones) { @@ -227,7 +219,7 @@ void icalcomponent_free(icalcomponent *c) c->id[0] = 'X'; c->timezones = NULL; - free(c); + icalmemory_free_buffer(c); } } @@ -236,7 +228,9 @@ char *icalcomponent_as_ical_string(icalcomponent *impl) char *buf; buf = icalcomponent_as_ical_string_r(impl); - icalmemory_add_tmp_buffer(buf); + if (buf) { + icalmemory_add_tmp_buffer(buf); + } return buf; } @@ -269,6 +263,9 @@ char *icalcomponent_as_ical_string_r(icalcomponent *impl) icalerror_check_arg_rz((kind_string != 0), "Unknown kind of component"); buf = icalmemory_new_buffer(buf_size); + if (buf == NULL) + return NULL; + buf_ptr = buf; icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:"); @@ -282,16 +279,17 @@ char *icalcomponent_as_ical_string_r(icalcomponent *impl) tmp_buf = icalproperty_as_ical_string_r(p); icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); - free(tmp_buf); + icalmemory_free_buffer(tmp_buf); } for (itr = pvl_head(impl->components); itr != 0; itr = pvl_next(itr)) { c = (icalcomponent *) pvl_data(itr); tmp_buf = icalcomponent_as_ical_string_r(c); - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); - free(tmp_buf); + if (tmp_buf != NULL) { + icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); + icalmemory_free_buffer(tmp_buf); + } } icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:"); @@ -532,7 +530,8 @@ void icalcomponent_add_component(icalcomponent *parent, icalcomponent *child) if (!parent->timezones) parent->timezones = icaltimezone_array_new(); - icaltimezone_array_append_from_vtimezone(parent->timezones, child); + if (parent->timezones) + icaltimezone_array_append_from_vtimezone(parent->timezones, child); /* Flag that we need to sort it before doing any binary searches. */ parent->timezones_sorted = 0; @@ -726,24 +725,14 @@ or empty VCALENDAR component"); */ } span.start = icaltime_as_timet_with_zone(start, icaltimezone_get_utc_timezone()); - /* The end time could be specified as either a DTEND or a DURATION */ + /* The end time could be specified as either a DTEND, a DURATION, or be missing */ /* icalcomponent_get_dtend takes care of these cases. */ end = icalcomponent_get_dtend(comp); - if (icaltime_is_null_time(end)) { - if (!icaltime_is_date(start)) { - /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION - it takes no time */ - span.start = 0; - return span; - } else { - end = start; - } - } span.end = icaltime_as_timet_with_zone(end, icaltimezone_get_utc_timezone()); if (icaltime_is_date(start)) { /* Until the end of the day */ - span.end += 60 * 60 * 24 - 1; + span.end -= 1; } return span; @@ -806,7 +795,8 @@ int icalproperty_recurrence_is_excluded(icalcomponent *comp, /** exrule_time > recurtime **/ } - icalrecur_iterator_free(exrule_itr); + if (exrule_itr) + icalrecur_iterator_free(exrule_itr); } comp->property_iterator = property_iterator; @@ -873,8 +863,8 @@ void icalcomponent_foreach_recurrence(icalcomponent *comp, { struct icaltimetype dtstart, dtend; icaltime_span recurspan, basespan, limit_span; - time_t limit_start, limit_end; - time_t dtduration; + icaltime_t limit_start, limit_end; + icaltime_t dtduration; icalproperty *rrule, *rdate; pvl_elem property_iterator; /* for saving the iterator */ @@ -891,16 +881,9 @@ void icalcomponent_foreach_recurrence(icalcomponent *comp, if (icaltime_is_null_time(dtstart)) return; - /* The end time could be specified as either a DTEND or a DURATION */ + /* The end time could be specified as either a DTEND, a DURATION or be missing */ /* icalcomponent_get_dtend takes care of these cases. */ dtend = icalcomponent_get_dtend(comp); - if (icaltime_is_null_time(dtend) && icaltime_is_date(dtstart)) { - /* No DTEND or DURATION and DTSTART is DATE - duration is 1 day */ - struct icaldurationtype dur = icaldurationtype_null_duration(); - - dur.days = 1; - dtend = icaltime_add(dtstart, dur); - } /* Now set up the base span for this item, corresponding to the base DTSTART and DTEND */ @@ -915,10 +898,10 @@ void icalcomponent_foreach_recurrence(icalcomponent *comp, limit_end = icaltime_as_timet_with_zone(end, icaltimezone_get_utc_timezone()); } else { -#if (SIZEOF_TIME_T > 4) - limit_end = (time_t) LONG_MAX; +#if (SIZEOF_ICALTIME_T > 4) + limit_end = (icaltime_t) LONG_MAX; #else - limit_end = (time_t) INT_MAX; + limit_end = (icaltime_t) INT_MAX; #endif } limit_span.start = limit_start; @@ -1199,6 +1182,11 @@ static const struct icalcomponent_kind_map component_map[] = { {ICAL_VPATCH_COMPONENT, "VPATCH"}, {ICAL_XPATCH_COMPONENT, "PATCH"}, + /* Event Publishing components */ + {ICAL_PARTICIPANT_COMPONENT, "PARTICIPANT"}, + {ICAL_VLOCATION_COMPONENT, "VLOCATION"}, + {ICAL_VRESOURCE_COMPONENT, "VRESOURCE"}, + /* End of list */ {ICAL_NO_COMPONENT, ""}, }; @@ -1423,13 +1411,26 @@ struct icaltimetype icalcomponent_get_dtstart(icalcomponent *comp) struct icaltimetype icalcomponent_get_dtend(icalcomponent *comp) { icalcomponent *inner = icalcomponent_get_inner(comp); - icalproperty *end_prop = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY); - icalproperty *dur_prop = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - struct icaltimetype ret = icaltime_null_time(); + const icalcomponent_kind kind = icalcomponent_isa(inner); + icalproperty *end_prop, *dur_prop; + struct icaltimetype ret; + + switch(kind) { + case ICAL_VAVAILABILITY_COMPONENT: + case ICAL_VEVENT_COMPONENT: + case ICAL_VFREEBUSY_COMPONENT: + case ICAL_XAVAILABLE_COMPONENT: + break; + default: + return icaltime_null_time(); + } + + end_prop = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY); + dur_prop = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - if (end_prop != 0) { + if (end_prop != 0 && dur_prop == 0) { ret = icalproperty_get_datetime_with_component(end_prop, comp); - } else if (dur_prop != 0) { + } else if (end_prop == 0 && dur_prop != 0) { struct icaltimetype start = icalcomponent_get_dtstart(inner); struct icaldurationtype duration; @@ -1442,6 +1443,23 @@ struct icaltimetype icalcomponent_get_dtend(icalcomponent *comp) } ret = icaltime_add(start, duration); + } else if (end_prop == 0 && dur_prop == 0) { + if (kind == ICAL_VEVENT_COMPONENT) { + struct icaltimetype start = icalcomponent_get_dtstart(inner); + if (icaltime_is_date(start)) { + struct icaldurationtype duration = icaldurationtype_null_duration(); + duration.days = 1; + ret = icaltime_add(start, duration); + } else { + ret = start; + } + } else { + ret = icaltime_null_time(); + } + } else { + /* Error, both duration and dtend have been specified */ + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); + ret = icaltime_null_time(); } return ret; @@ -1492,12 +1510,32 @@ void icalcomponent_set_duration(icalcomponent *comp, struct icaldurationtype v) struct icaldurationtype icalcomponent_get_duration(icalcomponent *comp) { icalcomponent *inner = icalcomponent_get_inner(comp); + const icalcomponent_kind kind = icalcomponent_isa(inner); + icalproperty *end_prop, *dur_prop; + struct icaltimetype end; + struct icaldurationtype ret; + + switch(kind) { + case ICAL_VAVAILABILITY_COMPONENT: + case ICAL_VEVENT_COMPONENT: + case ICAL_XAVAILABLE_COMPONENT: + end_prop = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY); + if (end_prop) { + end = icalcomponent_get_dtend(inner); + } + break; + case ICAL_VTODO_COMPONENT: + end_prop = icalcomponent_get_first_property(inner, ICAL_DUE_PROPERTY); + if (end_prop) { + end = icalcomponent_get_due(inner); + } + break; + default: + /* The libical API is used incorrectly */ + return icaldurationtype_null_duration(); + } - icalproperty *end_prop = icalcomponent_get_first_property(inner, ICAL_DTEND_PROPERTY); - - icalproperty *dur_prop = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - - struct icaldurationtype ret = icaldurationtype_null_duration(); + dur_prop = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); if (dur_prop != 0 && end_prop == 0) { ret = icalproperty_get_duration(dur_prop); @@ -1506,13 +1544,19 @@ struct icaldurationtype icalcomponent_get_duration(icalcomponent *comp) /** * FIXME * We assume DTSTART and DTEND are not in different time zones. - * Does the standard actually guarantee this? + * The standard actually allows different time zones. */ struct icaltimetype start = icalcomponent_get_dtstart(inner); - struct icaltimetype end = icalcomponent_get_dtend(inner); ret = icaltime_subtract(end, start); + } else if (end_prop == 0 && dur_prop == 0) { + struct icaltimetype start = icalcomponent_get_dtstart(inner); + ret = icaldurationtype_null_duration(); + if (kind == ICAL_VEVENT_COMPONENT && icaltime_is_date(start)) { + ret.days = 1; + } } else { + ret = icaldurationtype_null_duration(); /* Error, both duration and dtend have been specified */ icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); } @@ -1921,6 +1965,21 @@ icalcomponent *icalcomponent_new_xpatch(void) return icalcomponent_new(ICAL_XPATCH_COMPONENT); } +icalcomponent *icalcomponent_new_participant(void) +{ + return icalcomponent_new(ICAL_PARTICIPANT_COMPONENT); +} + +icalcomponent *icalcomponent_new_vlocation(void) +{ + return icalcomponent_new(ICAL_VLOCATION_COMPONENT); +} + +icalcomponent *icalcomponent_new_vresource(void) +{ + return icalcomponent_new(ICAL_VRESOURCE_COMPONENT); +} + /* * Timezone stuff. */ @@ -1932,13 +1991,16 @@ void icalcomponent_merge_component(icalcomponent *comp, icalcomponent *comp_to_m size_t i; /* Check that both components are VCALENDAR components. */ - assert(icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT); - assert(icalcomponent_isa(comp_to_merge) == ICAL_VCALENDAR_COMPONENT); + icalassert(icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT); + icalassert(icalcomponent_isa(comp_to_merge) == ICAL_VCALENDAR_COMPONENT); /* Step through each subcomponent of comp_to_merge, looking for VTIMEZONEs. For each VTIMEZONE found, check if we need to add it to comp and if we need to rename it and all TZID references to it. */ tzids_to_rename = icalarray_new(sizeof(char *), 16); + if (!tzids_to_rename) + return; + subcomp = icalcomponent_get_first_component(comp_to_merge, ICAL_VTIMEZONE_COMPONENT); while (subcomp) { next_subcomp = icalcomponent_get_next_component(comp_to_merge, ICAL_VTIMEZONE_COMPONENT); @@ -1956,7 +2018,7 @@ void icalcomponent_merge_component(icalcomponent *comp, icalcomponent *comp_to_m /* Now free the tzids_to_rename array. */ for (i = 0; i < tzids_to_rename->num_elements; i++) { - free(icalarray_element_at(tzids_to_rename, i)); + icalmemory_free_buffer(icalarray_element_at(tzids_to_rename, i)); } } icalarray_free(tzids_to_rename); @@ -2015,7 +2077,7 @@ static void icalcomponent_merge_vtimezone(icalcomponent *comp, unique one), so we compare the VTIMEZONE components to see if they are the same. If they are, we don't need to do anything. We make a copy of the tzid, since the parameter may get modified in these calls. */ - tzid_copy = strdup(tzid); + tzid_copy = icalmemory_strdup(tzid); if (!tzid_copy) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return; @@ -2028,7 +2090,7 @@ static void icalcomponent_merge_vtimezone(icalcomponent *comp, icalcomponent_handle_conflicting_vtimezones(comp, vtimezone, tzid_prop, tzid_copy, tzids_to_rename); } - free(tzid_copy); + icalmemory_free_buffer(tzid_copy); } static void icalcomponent_handle_conflicting_vtimezones(icalcomponent *comp, @@ -2072,20 +2134,20 @@ static void icalcomponent_handle_conflicting_vtimezones(icalcomponent *comp, if (icalcomponent_compare_vtimezones(icaltimezone_get_component(zone), vtimezone)) { /* The VTIMEZONEs match, so we can use the existing VTIMEZONE. But we have to rename TZIDs to this TZID. */ - tzid_copy = strdup(tzid); + tzid_copy = icalmemory_strdup(tzid); if (!tzid_copy) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return; } - existing_tzid_copy = strdup(existing_tzid); + existing_tzid_copy = icalmemory_strdup(existing_tzid); if (!existing_tzid_copy) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(tzid_copy); + icalmemory_free_buffer(tzid_copy); } else { icalarray_append(tzids_to_rename, tzid_copy); - free(tzid_copy); + icalmemory_free_buffer(tzid_copy); icalarray_append(tzids_to_rename, existing_tzid_copy); - free(existing_tzid_copy); + icalmemory_free_buffer(existing_tzid_copy); } return; } else { @@ -2102,17 +2164,17 @@ static void icalcomponent_handle_conflicting_vtimezones(icalcomponent *comp, /* We didn't find a VTIMEZONE that matched, so we have to rename the TZID, using the maximum numerical suffix found + 1. */ - tzid_copy = strdup(tzid); + tzid_copy = icalmemory_strdup(tzid); if (!tzid_copy) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return; } snprintf(suffix_buf, sizeof(suffix_buf), "%i", max_suffix + 1); - new_tzid = malloc(tzid_len + strlen(suffix_buf) + 1); + new_tzid = icalmemory_new_buffer(tzid_len + strlen(suffix_buf) + 1); if (!new_tzid) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(tzid_copy); + icalmemory_free_buffer(tzid_copy); return; } @@ -2120,8 +2182,8 @@ static void icalcomponent_handle_conflicting_vtimezones(icalcomponent *comp, strcpy(new_tzid + tzid_len, suffix_buf); icalarray_append(tzids_to_rename, tzid_copy); icalarray_append(tzids_to_rename, new_tzid); - free(tzid_copy); - free(new_tzid); + icalmemory_free_buffer(tzid_copy); + icalmemory_free_buffer(new_tzid); } /* Returns the length of the TZID, without any trailing digits. */ @@ -2294,7 +2356,7 @@ static int icalcomponent_compare_vtimezones(icalcomponent *vtimezone1, icalcompo /* Copy the second TZID, and set the property to the same as the first TZID, since we don't care if these match of not. */ - tzid2_copy = strdup(tzid2); + tzid2_copy = icalmemory_strdup(tzid2); if (!tzid2_copy) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; @@ -2305,25 +2367,25 @@ static int icalcomponent_compare_vtimezones(icalcomponent *vtimezone1, icalcompo /* Now convert both VTIMEZONEs to strings and compare them. */ string1 = icalcomponent_as_ical_string_r(vtimezone1); if (!string1) { - free(tzid2_copy); + icalmemory_free_buffer(tzid2_copy); return -1; } string2 = icalcomponent_as_ical_string_r(vtimezone2); if (!string2) { - free(string1); - free(tzid2_copy); + icalmemory_free_buffer(string1); + icalmemory_free_buffer(tzid2_copy); return -1; } cmp = strcmp(string1, string2); - free(string1); - free(string2); + icalmemory_free_buffer(string1); + icalmemory_free_buffer(string2); /* Now reset the second TZID. */ icalproperty_set_tzid(prop2, tzid2_copy); - free(tzid2_copy); + icalmemory_free_buffer(tzid2_copy); return (cmp == 0) ? 1 : 0; } @@ -2412,6 +2474,7 @@ void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v) icalcomponent_add_property(inner, due_prop); } else if (due_prop != 0) { icalproperty_set_due(due_prop, v); + icalproperty_remove_parameter_by_kind(due_prop, ICAL_TZID_PARAMETER); } else if (dur_prop != 0) { struct icaltimetype start = icalcomponent_get_dtstart(inner); @@ -2427,6 +2490,12 @@ void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v) } } +static int strcmpsafe(const char *a, const char *b) +{ + return strcmp((a == NULL ? "" : a), + (b == NULL ? "" : b)); +} + static int prop_compare(void *a, void *b) { icalproperty *p1 = (icalproperty*) a; @@ -2442,8 +2511,8 @@ static int prop_compare(void *a, void *b) } if (r == 0) { - r = strcmp(icalproperty_get_value_as_string(p1), - icalproperty_get_value_as_string(p2)); + r = strcmpsafe(icalproperty_get_value_as_string(p1), + icalproperty_get_value_as_string(p2)); } } diff --git a/src/libical/icalcomponent.h b/src/libical/icalcomponent.h index 8b68c5e7..69d6c72e 100644 --- a/src/libical/icalcomponent.h +++ b/src/libical/icalcomponent.h @@ -2,18 +2,10 @@ FILE: icalcomponent.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /** @@ -281,6 +273,13 @@ LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtstart(icalcomponent * there is a DTEND and you call get_duration, the routine will * return the difference between DTEND and DTSTART. * + * When DURATION and DTEND are both missing, for VEVENT an implicit + * DTEND is calculated based of DTSTART; for AVAILABLE, VAVAILABILITY, + * and VFREEBUSY null-time is returned. + * + * Returns null-time, unless called on AVAILABLE, VEVENT, + * VAVAILABILITY, or VFREEBUSY components. + * * FIXME this is useless until we can flag the failure */ LIBICAL_ICAL_EXPORT struct icaltimetype icalcomponent_get_dtend(icalcomponent *comp); @@ -345,15 +344,14 @@ LIBICAL_ICAL_EXPORT void icalcomponent_set_duration(icalcomponent *comp, /** @brief Gets the DURATION property as an icalduration * * For the icalcomponent routines only, DTEND and DURATION are tied - * together. - * If a DURATION property is not present but a DTEND is, we use - * that to determine the proper end. - * - * For the icalcomponent routines only, dtend and duration are tied * together. If you call the get routine for one and the other * exists, the routine will calculate the return value. That is, if - * there is a DTEND and you call get_duration, the routine will - * return the difference between DTEND and DTSTART. + * there is a DTEND and you call get_duration, the routine will return + * the difference between DTEND and DTSTART in AVAILABLE, VEVENT, or + * VAVAILABILITY; and the difference between DUE and DTSTART in VTODO. + * When both DURATION and DTEND are missing from VEVENT an implicit + * duration is returned, based on the value-type of DTSTART. Otherwise + * null-duration is returned. */ LIBICAL_ICAL_EXPORT struct icaldurationtype icalcomponent_get_duration(icalcomponent *comp); @@ -461,8 +459,8 @@ LIBICAL_ICAL_EXPORT int icalproperty_recurrence_is_excluded(icalcomponent *comp, * * It will filter out events that are specified as an EXDATE or an EXRULE. * - * @todo We do not filter out duplicate RRULES/RDATES - * @todo We do not handle RDATEs with explicit periods + * TODO: We do not filter out duplicate RRULES/RDATES + * TODO: We do not handle RDATEs with explicit periods */ LIBICAL_ICAL_EXPORT void icalcomponent_foreach_recurrence(icalcomponent *comp, struct icaltimetype start, @@ -529,4 +527,10 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vpatch(void); LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_xpatch(void); +LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_participant(void); + +LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vlocation(void); + +LIBICAL_ICAL_EXPORT icalcomponent *icalcomponent_new_vresource(void); + #endif /* !ICALCOMPONENT_H */ diff --git a/src/libical/icalderivedparameter.c.in b/src/libical/icalderivedparameter.c.in index f0af1fe7..0e203179 100644 --- a/src/libical/icalderivedparameter.c.in +++ b/src/libical/icalderivedparameter.c.in @@ -2,18 +2,9 @@ FILE: icalderivedparameters.{c,h} CREATOR: eric 09 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 Contributions from: Graham Davison (g.m.davison@computer.org) diff --git a/src/libical/icalderivedparameter.h.in b/src/libical/icalderivedparameter.h.in index 9bb58fca..07649533 100644 --- a/src/libical/icalderivedparameter.h.in +++ b/src/libical/icalderivedparameter.h.in @@ -2,18 +2,9 @@ FILE: icalparam.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalparam.h ======================================================================*/ diff --git a/src/libical/icalderivedproperty.c.in b/src/libical/icalderivedproperty.c.in index 93883b3a..62cbf6d1 100644 --- a/src/libical/icalderivedproperty.c.in +++ b/src/libical/icalderivedproperty.c.in @@ -2,18 +2,10 @@ FILE: icalderivedproperty.c CREATOR: eric 09 May 1999 - (C) COPYRIGHT 1999, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H diff --git a/src/libical/icalderivedproperty.h.in b/src/libical/icalderivedproperty.h.in index 0ebec067..c5244dd8 100644 --- a/src/libical/icalderivedproperty.h.in +++ b/src/libical/icalderivedproperty.h.in @@ -2,24 +2,15 @@ FILE: icalderivedproperty.h CREATOR: eric 09 May 1999 - (C) COPYRIGHT 1999, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALDERIVEDPROPERTY_H #define ICALDERIVEDPROPERTY_H -#include <time.h> #include "icalparameter.h" #include "icalderivedvalue.h" #include "icalrecur.h" diff --git a/src/libical/icalderivedvalue.c.in b/src/libical/icalderivedvalue.c.in index 2727e0b4..8dde33eb 100644 --- a/src/libical/icalderivedvalue.c.in +++ b/src/libical/icalderivedvalue.c.in @@ -2,18 +2,9 @@ FILE: icalvalue.c CREATOR: eric 02 May 1999 - (C) COPYRIGHT 1999, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 Contributions from: Graham Davison (g.m.davison@computer.org) @@ -28,6 +19,7 @@ #include "icalvalueimpl.h" #include "icalerror.h" #include "icalmemory.h" +#include "icaltimezone.h" #include <errno.h> #include <stdlib.h> @@ -114,7 +106,7 @@ void icalvalue_set_x(icalvalue *impl, const char *v) icalerror_check_arg_rv((v != 0), "v"); if (impl->x_value != 0) { - free((void *)impl->x_value); + icalmemory_free_buffer((void *)impl->x_value); } impl->x_value = icalmemory_strdup(v); @@ -150,12 +142,12 @@ void icalvalue_set_recur(icalvalue *impl, struct icalrecurrencetype v) icalerror_check_value_type(value, ICAL_RECUR_VALUE); if (impl->data.v_recur != 0) { - free(impl->data.v_recur->rscale); - free(impl->data.v_recur); + icalmemory_free_buffer(impl->data.v_recur->rscale); + icalmemory_free_buffer(impl->data.v_recur); impl->data.v_recur = 0; } - impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype)); + impl->data.v_recur = icalmemory_new_buffer(sizeof(struct icalrecurrencetype)); if (impl->data.v_recur == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); @@ -299,6 +291,12 @@ void icalvalue_set_datetimedate(icalvalue *value, struct icaltimetype v) impl = (struct icalvalue_impl *)value; impl->data.v_time = v; + /* preserve only built-in UTC time zone, otherwise unset any set on the 'v' */ + if (impl->data.v_time.zone != NULL && + impl->data.v_time.zone != icaltimezone_get_utc_timezone()) { + impl->data.v_time.zone = NULL; + } + icalvalue_reset_kind(impl); } @@ -432,9 +430,8 @@ void icalvalue_set_geo(icalvalue *value, struct icalgeotype v) struct icalgeotype icalvalue_get_geo(const icalvalue *value) { struct icalgeotype gt; - - gt.lat = 255.0; - gt.lon = 255.0; + strcpy(gt.lat, "255.0"); + strcpy(gt.lon, "255.0"); icalerror_check_arg_rx((value != 0), "value", gt); icalerror_check_value_type(value, ICAL_GEO_VALUE); diff --git a/src/libical/icalderivedvalue.h.in b/src/libical/icalderivedvalue.h.in index 52f57418..65ed8588 100644 --- a/src/libical/icalderivedvalue.h.in +++ b/src/libical/icalderivedvalue.h.in @@ -2,18 +2,10 @@ FILE: icalvalue.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 1999, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALDERIVEDVALUE_H diff --git a/src/libical/icalduration.c b/src/libical/icalduration.c index c978fb79..e6780f59 100644 --- a/src/libical/icalduration.c +++ b/src/libical/icalduration.c @@ -2,18 +2,9 @@ FILE: icaltime.c CREATOR: eric 02 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -338,8 +329,8 @@ struct icaltimetype icaltime_add(struct icaltimetype t, struct icaldurationtype struct icaldurationtype icaltime_subtract(struct icaltimetype t1, struct icaltimetype t2) { - time_t t1t = icaltime_as_timet(t1); - time_t t2t = icaltime_as_timet(t2); + icaltime_t t1t = icaltime_as_timet(t1); + icaltime_t t2t = icaltime_as_timet(t2); return icaldurationtype_from_int((int)(t1t - t2t)); } diff --git a/src/libical/icalduration.h b/src/libical/icalduration.h index 228dab7c..a6723770 100644 --- a/src/libical/icalduration.h +++ b/src/libical/icalduration.h @@ -2,18 +2,9 @@ FILE: icalduration.h CREATOR: eric 26 Jan 2001 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -50,7 +41,7 @@ struct icaldurationtype * @param t The duration in seconds * @return An ::icaldurationtype representing the duration @a t in seconds * - * ### Example + * @par Example * ```c * // create a new icaldurationtype with a duration of 60 seconds * struct icaldurationtype duration; @@ -71,7 +62,7 @@ LIBICAL_ICAL_EXPORT struct icaldurationtype icaldurationtype_from_int(int t); * When given bad input, it sets ::icalerrno to ::ICAL_MALFORMEDDATA_ERROR and * returns icaldurationtype_bad_duration(). * - * ### Usage + * @par Usage * ```c * // create a new icaldurationtype * struct icaldurationtype duration; @@ -88,7 +79,7 @@ LIBICAL_ICAL_EXPORT struct icaldurationtype icaldurationtype_from_string(const c * @param duration The duration to convert to seconds * @return An `int` representing the duration in seconds * - * ### Usage + * @par Usage * ```c * // create icaldurationtype with given duration * struct icaldurationtype duration; @@ -102,15 +93,15 @@ LIBICAL_ICAL_EXPORT int icaldurationtype_as_int(struct icaldurationtype duration /** * Converts an icaldurationtype into the iCal format as string. - * @param The icaldurationtype to convert to iCal format + * @param d is the icaldurationtype to convert to iCal format * @return A string representing duration @p d in iCal format * @sa icaldurationtype_as_ical_string_r() * - * @b Ownership + * @par Ownership * The string returned by this function is owned by the caller and needs to be - * released with `free()` after it's no longer needed. + * released with `icalmemory_free_buffer()` after it's no longer needed. * - * @b Usage + * @par Usage * ```c * // create new duration * struct icaldurationtype duration; @@ -121,22 +112,22 @@ LIBICAL_ICAL_EXPORT int icaldurationtype_as_int(struct icaldurationtype duration * printf("%s\n", ical); * * // release string - * free(ical); + * icalmemory_free_buffer(ical); * ``` */ LIBICAL_ICAL_EXPORT char *icaldurationtype_as_ical_string(struct icaldurationtype d); /** * Converts an icaldurationtype into the iCal format as string. - * @param The icaldurationtype to convert to iCal format + * @param d is the icaldurationtype to convert to iCal format * @return A string representing duration @p d in iCal format * @sa icaldurationtype_as_ical_string() * - * @b Ownership + * @par Ownership * The string returned by this function is owned by libical and must not be * released by the caller of the function. * - * @b Usage + * @par Usage * ```c * // create new duration * struct icaldurationtype duration; @@ -153,7 +144,7 @@ LIBICAL_ICAL_EXPORT char *icaldurationtype_as_ical_string_r(struct icaldurationt * @return An ::icaldurationtype with a zero length * @sa icaldurationtype_is_null_duration() * - * ### Usage + * @par Usage * ```c * // create null duration * struct icaldurationtype duration; @@ -176,7 +167,7 @@ LIBICAL_ICAL_EXPORT struct icaldurationtype icaldurationtype_null_duration(void) * @return A bad duration * @sa icaldurationtype_is_bad_duration() * - * ### Usage + * @par Usage * ```c * // create bad duration * struct icaldurationtype duration; @@ -194,7 +185,7 @@ LIBICAL_ICAL_EXPORT struct icaldurationtype icaldurationtype_bad_duration(void); * @return 1 if the duration is a null duration, 0 otherwise * @sa icalduration_null_duration() * - * ### Usage + * @par Usage * ``` * // make null duration * struct icaldurationtype duration; @@ -212,7 +203,7 @@ LIBICAL_ICAL_EXPORT int icaldurationtype_is_null_duration(struct icaldurationtyp * @return 1 if the duration is a bad duration, 0 otherwise * @sa icalduration_bad_duration() * - * ### Usage + * @par Usage * ``` * // make bad duration * struct icaldurationtype duration; @@ -225,12 +216,12 @@ LIBICAL_ICAL_EXPORT int icaldurationtype_is_null_duration(struct icaldurationtyp LIBICAL_ICAL_EXPORT int icaldurationtype_is_bad_duration(struct icaldurationtype d); /** - * @brief Adds a duration to an ::icaltime object and returns the result. + * @brief Adds a duration to an icaltime object and returns the result. * @param t The time object to add the duration to * @param d The duration to add to the time object * @return The new ::icaltimetype which has been added the duration to * - * ### Example + * @par Example * ```c * struct icaltimetype time; * struct icaldurationtype duration; @@ -253,7 +244,7 @@ LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_add(struct icaltimetype t, * @return An ::icaldurationtype representing the duration the elapsed between * @a t1 and @a t2 * - * ### Usage + * @par Usage * ```c * struct icaltimetype t1 = icaltime_from_day_of_year(111, 2018); * struct icaltimetype t2 = icaltime_from_day_of_year(112, 2018); diff --git a/src/libical/icalenums.c b/src/libical/icalenums.c index 4e184795..954a7832 100644 --- a/src/libical/icalenums.c +++ b/src/libical/icalenums.c @@ -2,18 +2,10 @@ FILE: icalenum.c CREATOR: eric 29 April 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -81,7 +73,8 @@ const char *icalenum_reqstat_desc(icalrequeststatus stat) { int i; - for (i = 0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { + int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0])); + for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { if (request_status_map[i].kind == stat) { return request_status_map[i].str; } @@ -104,7 +97,8 @@ char *icalenum_reqstat_code_r(icalrequeststatus stat) int i, major, minor; char tmpbuf[36]; - for (i = 0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { + int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0])); + for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { if (request_status_map[i].kind == stat) { major = request_status_map[i].major; minor = request_status_map[i].minor; @@ -119,7 +113,8 @@ short icalenum_reqstat_major(icalrequeststatus stat) { int i; - for (i = 0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { + int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0])); + for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { if (request_status_map[i].kind == stat) { return request_status_map[i].major; } @@ -131,7 +126,8 @@ short icalenum_reqstat_minor(icalrequeststatus stat) { int i; - for (i = 0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { + int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0])); + for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { if (request_status_map[i].kind == stat) { return request_status_map[i].minor; } @@ -143,7 +139,8 @@ icalrequeststatus icalenum_num_to_reqstat(short major, short minor) { int i; - for (i = 0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { + int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0])); + for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { if (request_status_map[i].major == major && request_status_map[i].minor == minor) { return request_status_map[i].kind; } diff --git a/src/libical/icalenums.h b/src/libical/icalenums.h index 6d3ac09e..8c72a008 100644 --- a/src/libical/icalenums.h +++ b/src/libical/icalenums.h @@ -1,18 +1,9 @@ /*====================================================================== FILE: icalenums.h - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 Contributions from: Graham Davison <g.m.davison@computer.org> @@ -64,7 +55,11 @@ typedef enum icalcomponent_kind ICAL_VVOTER_COMPONENT, ICAL_XVOTE_COMPONENT, ICAL_VPATCH_COMPONENT, - ICAL_XPATCH_COMPONENT + ICAL_XPATCH_COMPONENT, + ICAL_PARTICIPANT_COMPONENT, + ICAL_VLOCATION_COMPONENT, + ICAL_VRESOURCE_COMPONENT, + ICAL_NUM_COMPONENT_TYPES /* MUST be last (unless we can put NO_COMP last) */ } icalcomponent_kind; /*********************************************************************** diff --git a/src/libical/icalerror.c b/src/libical/icalerror.c index 12071ff8..1e6e4602 100644 --- a/src/libical/icalerror.c +++ b/src/libical/icalerror.c @@ -2,18 +2,9 @@ FILE: icalerror.c CREATOR: eric 16 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalerror.c ======================================================================*/ @@ -23,6 +14,7 @@ #endif #include "icalerror.h" +#include "icalmemory.h" #include <stdlib.h> @@ -38,7 +30,7 @@ static pthread_once_t icalerrno_key_once = PTHREAD_ONCE_INIT; static void icalerrno_destroy(void *buf) { - free(buf); + icalmemory_free_buffer(buf); pthread_setspecific(icalerrno_key, NULL); } @@ -56,7 +48,7 @@ icalerrorenum *icalerrno_return(void) _errno = (icalerrorenum *) pthread_getspecific(icalerrno_key); if (!_errno) { - _errno = malloc(sizeof(icalerrorenum)); + _errno = icalmemory_new_buffer(sizeof(icalerrorenum)); *_errno = ICAL_NO_ERROR; pthread_setspecific(icalerrno_key, _errno); } @@ -90,7 +82,7 @@ void icalerror_crash_here(void) *p = 1; /* cppcheck-suppress nullPointer */ - assert(*p); + icalassert(*p); #endif } @@ -123,7 +115,7 @@ void icalerror_set_errno(icalerrorenum x) (icalerror_get_error_state(x) == ICAL_ERROR_DEFAULT && icalerror_errors_are_fatal == 1)) { icalerror_warn(icalerror_strerror(x)); ical_bt(); - assert(0); + icalassert(0); } } @@ -272,11 +264,11 @@ void ical_bt(void) strings = backtrace_symbols(stack_frames, num); for (i = 0; i < num; i++) { if (strings != NULL) { - fprintf(stderr, "%s\n", strings[i]); + icalerrprintf("%s\n", strings[i]); } else { - fprintf(stderr, "%p\n", stack_frames[i]); + icalerrprintf("%p\n", stack_frames[i]); } } - free(strings); + icalmemory_free_buffer(strings); #endif } diff --git a/src/libical/icalerror.h b/src/libical/icalerror.h index 7fd1253a..87ed8a98 100644 --- a/src/libical/icalerror.h +++ b/src/libical/icalerror.h @@ -2,18 +2,9 @@ FILE: icalerror.h CREATOR: eric 09 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalerror.h ======================================================================*/ @@ -118,7 +109,7 @@ typedef enum icalerrorenum * Yields a pointer to the current ::icalerrno value. This can * be used to access (read from and write to) it. * - * ### Examples + * @par Examples * ```c * assert(*icalerrno_return() == icalerrno); * ``` @@ -131,7 +122,7 @@ LIBICAL_ICAL_EXPORT icalerrorenum *icalerrno_return(void); * @note Pseudo-variable that can be used to access the current * ::icalerrno. * - * ### Usage + * @par Usage * ```c * if(icalerrno == ICAL_PARSE_ERROR) { * // ... @@ -149,7 +140,7 @@ LIBICAL_ICAL_EXPORT icalerrorenum *icalerrno_return(void); * @warning NOT THREAD SAFE: it is recommended that you do not change * this in a multithreaded program. * - * ### Usage + * @par Usage * ```c * icalerror_set_errors_are_fatal(true); // default * icalerror_set_errors_are_fatal(false); @@ -161,7 +152,7 @@ LIBICAL_ICAL_EXPORT void icalerror_set_errors_are_fatal(int fatal); * @brief Determine if errors are fatal * @return True if libical errors are fatal * - * ### Usage + * @par Usage * ```c * if(icalerror_get_errors_are_fatal()) { * // since errors are fatal, this will abort the @@ -179,7 +170,7 @@ LIBICAL_ICAL_EXPORT int icalerror_get_errors_are_fatal(void); * @brief Prints a formatted warning message to stderr * @param message Warning message to print * - * ### Usage + * @par Usage * ```c * icalerror_warn("Non-standard tag encountered"); * ``` @@ -187,16 +178,16 @@ LIBICAL_ICAL_EXPORT int icalerror_get_errors_are_fatal(void); #ifdef __GNUC__ca #define icalerror_warn(message) \ -{fprintf(stderr, "%s(), %s:%d: %s\n", __FUNCTION__, __FILE__, __LINE__, message);} +{icalerrprintf("%s(), %s:%d: %s\n", __FUNCTION__, __FILE__, __LINE__, message);} #else /* __GNU_C__ */ #define icalerror_warn(message) \ -{fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, message);} +{icalerrprintf("%s:%d: %s\n", __FILE__, __LINE__, message);} #endif /* __GNU_C__ */ /** * @brief Resets icalerrno to ::ICAL_NO_ERROR * - * ### Usage + * @par Usage * ```c * if(icalerrno == ICAL_PARSE_ERROR) { * // ignore parsing errors @@ -239,7 +230,7 @@ typedef enum icalerrorstate * The string that is returned is owned by the library and must not * be free'd() by the user. * - * ### Usage + * @par Usage * ```c * if(icalerrno != ICAL_NO_ERROR) { * printf("%s\n", icalerror_strerror(icalerrno)); @@ -259,7 +250,7 @@ LIBICAL_ICAL_EXPORT const char *icalerror_strerror(icalerrorenum e); * The string that is returned is owned by the library and must not * be free'd() by the user. * - * ### Usage + * @par Usage * ```c * if(icalerrno != ICAL_NO_ERROR) { * printf("%s\n", icalerror_perror()); @@ -272,7 +263,7 @@ LIBICAL_ICAL_EXPORT const char *icalerror_perror(void); * @brief Prints backtrace * @note Only works on systems that support it (HAVE_BACKTRACE enabled). * - * ### Usage + * @par Usage * ``` * if(icalerrno != ICAL_NO_ERROR) { * ical_bt(); @@ -289,7 +280,7 @@ LIBICAL_ICAL_EXPORT void ical_bt(void); * Sets the severity of a given error. For example, it can be used to * set the severity of an ::ICAL_PARSE_ERROR to be an ::ICAL_ERROR_NONFATAL. * - * ### Usage + * @par Usage * ```c * icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL); * ``` @@ -312,7 +303,7 @@ LIBICAL_ICAL_EXPORT icalerrorstate icalerror_get_error_state(icalerrorenum error * If the error specified in @a str can't be found, instead * ::ICAL_UNKNOWN_ERROR is returned. * - * ### Usage + * @par Usage * ```c * assert(icalerror_error_from_string("PARSE") == ICAL_PARSE_ERROR); * assert(icalerror_error_from_string("NONSENSE") == ICAL_UNKNOWN_ERROR); @@ -330,7 +321,7 @@ LIBICAL_ICAL_EXPORT icalerrorenum icalerror_error_from_string(const char *str); * and ::ICAL_ERRORS_ARE_FATAL is true, it prints a warning to @a stderr * and aborts the process. * - * ### Usage + * @par Usage * ```c * icalerror_set_errno(ICAL_PARSE_ERROR); * ``` @@ -343,7 +334,7 @@ if(icalerror_get_error_state(x) == ICAL_ERROR_FATAL || \ icalerror_get_errors_are_fatal() == 1)){ \ icalerror_warn(icalerror_strerror(x)); \ ical_bt(); \ - assert(0); \ + icalassert(0); \ } } #else /** @@ -355,7 +346,7 @@ if(icalerror_get_error_state(x) == ICAL_ERROR_FATAL || \ * and ::ICAL_ERRORS_ARE_FATAL is true, it prints a warning to @a stderr * and aborts the process. * - * ### Usage + * @par Usage * ```c * icalerror_set_errno(ICAL_PARSE_ERROR); * ``` @@ -405,13 +396,13 @@ LIBICAL_ICAL_EXPORT void icalerror_set_errno(icalerrorenum x); #ifdef __GNUC__ #define icalerror_assert(test,message) \ if (!(test)) { \ - fprintf(stderr, "%s(), %s:%d: %s\n", __FUNCTION__, __FILE__, __LINE__, message); \ + icalerrprintf("%s(), %s:%d: %s\n", __FUNCTION__, __FILE__, __LINE__, message); \ icalerror_stop_here(); \ abort();} #else /*__GNUC__*/ #define icalerror_assert(test,message) \ if (!(test)) { \ - fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, message); \ + icalerrprintf("%s:%d: %s\n", __FILE__, __LINE__, message); \ icalerror_stop_here(); \ abort();} #endif /*__GNUC__*/ @@ -429,7 +420,7 @@ if (!(test)) { \ * test if the parameter @a arg is correct. If the assertion fails, * it sets ::icalerrno to ::ICAL_BADARG_ERROR. * - * ### Example + * @par Example * ```c * void test_function(icalcomponent *component) { * icalerror_check_arg(component != 0, "component"); @@ -453,7 +444,7 @@ if (!(test)) { \ * it sets ::icalerrno to ::ICAL_BADARG_ERROR and causes the enclosing * function to return `void`. * - * ### Example + * @par Example * ```c * void test_function(icalcomponent *component) { * icalerror_check_arg_rv(component != 0, "component"); @@ -478,7 +469,7 @@ if (!(test)) { \ * it sets ::icalerrno to ::ICAL_BADARG_ERROR and causes the enclosing * function to return `0`. * - * ### Example + * @par Example * ```c * int test_function(icalcomponent *component) { * icalerror_check_arg_rz(component != 0, "component"); @@ -505,7 +496,7 @@ if (!(test)) { \ * it aborts the process with `assert(0)` and causes the enclosing * function to return @a error. * - * ### Example + * @par Example * ```c * icalcomponent *test_function(icalcomponent *component) { * icalerror_check_arg_re(component != 0, "component", NULL); @@ -518,7 +509,7 @@ if (!(test)) { \ #define icalerror_check_arg_re(test,arg,error) \ if (!(test)) { \ icalerror_stop_here(); \ - assert(0); \ + icalassert(0); \ return error; \ } @@ -533,7 +524,7 @@ if (!(test)) { \ * it sets ::icalerrno to ::ICAL_BADARG_ERROR and causes the enclosing * function to return @a x. * - * ### Example + * @par Example * ```c * icalcomponent *test_function(icalcomponent *component) { * icalerror_check_arg_rx(component != 0, "component", NULL); @@ -560,7 +551,7 @@ if (!(test)) { \ * ::ICAL_ERROR_NONFATAL, and thus suppressed. Error states can be * restored with icalerror_restore(). * - * ### Usage + * @par Usage * ```c * // suppresses internal errors * icalerror_supress("INTERNAL"); @@ -575,7 +566,7 @@ LIBICAL_ICAL_EXPORT icalerrorstate icalerror_supress(const char *error); * * Calling the function changes the ::icalerrorstate of the given error. * - * ### Usage + * @par Usage * ```c * // suppress internal errors * icalerror_supress("INTERNAL"); diff --git a/src/libical/icallangbind.c b/src/libical/icallangbind.c index 859d6c8e..03a973bb 100644 --- a/src/libical/icallangbind.c +++ b/src/libical/icallangbind.c @@ -2,18 +2,10 @@ FILE: icallangbind.c CREATOR: eric 15 dec 2000 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -29,14 +21,14 @@ int *icallangbind_new_array(int size) { - int *p = (int *)malloc(size * sizeof(int)); + int *p = (int *)icalmemory_new_buffer(size * sizeof(int)); return p; /* Caller handles failures */ } void icallangbind_free_array(int *array) { - free(array); + icalmemory_free_buffer(array); } int icallangbind_access_array(int *array, int index) @@ -195,7 +187,7 @@ char *icallangbind_property_eval_string_r(icalproperty *prop, const char *sep) default: { char *str = icalvalue_as_ical_string_r(value); - char *copy = (char *)malloc(strlen(str) + 1); + char *copy = (char *)icalmemory_new_buffer(strlen(str) + 1); const char *i; char *j; @@ -221,8 +213,8 @@ char *icallangbind_property_eval_string_r(icalproperty *prop, const char *sep) APPENDS(copy); APPENDC('\''); - free(copy); - free(str); + icalmemory_free_buffer(copy); + icalmemory_free_buffer(str); break; } } @@ -244,7 +236,7 @@ char *icallangbind_property_eval_string_r(icalproperty *prop, const char *sep) v = strchr(copy, '='); if (v == 0) { - free(copy); + icalmemory_free_buffer(copy); continue; } @@ -260,7 +252,7 @@ char *icallangbind_property_eval_string_r(icalproperty *prop, const char *sep) APPENDC('\''); APPENDS(v); APPENDC('\''); - free(copy); + icalmemory_free_buffer(copy); } APPENDC('}'); diff --git a/src/libical/icallangbind.h b/src/libical/icallangbind.h index c5ff8715..1ad4e10e 100644 --- a/src/libical/icallangbind.h +++ b/src/libical/icallangbind.h @@ -2,18 +2,10 @@ FILE: icallangbind.h CREATOR: eric 25 jan 2001 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALLANGBIND_H diff --git a/src/libical/icalmemory.c b/src/libical/icalmemory.c index 6c1bd9ca..2b5d0490 100644 --- a/src/libical/icalmemory.c +++ b/src/libical/icalmemory.c @@ -2,29 +2,9 @@ FILE: icalmemory.c CREATOR: eric 30 June 1999 - Copyright (C) 2000 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ - - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -33,6 +13,9 @@ #include "icalmemory.h" #include "icalerror.h" +#if defined(MEMORY_CONSISTENCY) +#include "test-malloc.h" +#endif #include <stdlib.h> @@ -74,10 +57,10 @@ static void icalmemory_free_ring_byval(buffer_ring * br) for (i = 0; i < BUFFER_RING_SIZE; i++) { if (br->ring[i] != 0) { - free(br->ring[i]); + icalmemory_free_buffer(br->ring[i]); } } - free(br); + icalmemory_free_buffer(br); } #if defined(HAVE_PTHREAD) @@ -109,7 +92,7 @@ static void icalmemory_free_tmp_buffer(void *buf) return; } - free(buf); + icalmemory_free_buffer(buf); } #endif @@ -122,7 +105,9 @@ static buffer_ring *buffer_ring_new(void) buffer_ring *br; int i; - br = (buffer_ring *) malloc(sizeof(buffer_ring)); + br = (buffer_ring *) icalmemory_new_buffer(sizeof(buffer_ring)); + if (!br) + return NULL; for (i = 0; i < BUFFER_RING_SIZE; i++) { br->ring[i] = 0; @@ -182,6 +167,9 @@ static buffer_ring *get_buffer_ring(void) void icalmemory_add_tmp_buffer(void *buf) { buffer_ring *br = get_buffer_ring(); + if (!br) { + return; + } /* Wrap around the ring */ if (++(br->pos) == BUFFER_RING_SIZE) { @@ -190,7 +178,7 @@ void icalmemory_add_tmp_buffer(void *buf) /* Free buffers as their slots are overwritten */ if (br->ring[br->pos] != 0) { - free(br->ring[br->pos]); + icalmemory_free_buffer(br->ring[br->pos]); } /* Assign the buffer to a slot */ @@ -210,7 +198,7 @@ void *icalmemory_tmp_buffer(size_t size) size = MIN_BUFFER_SIZE; } - buf = (void *)malloc(size); + buf = (void *)icalmemory_new_buffer(size); if (buf == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); @@ -229,6 +217,8 @@ void icalmemory_free_ring() buffer_ring *br; br = get_buffer_ring(); + if (!br) + return; icalmemory_free_ring_byval(br); #if defined(HAVE_PTHREAD) @@ -241,7 +231,15 @@ void icalmemory_free_ring() /* Like strdup, but the buffer is on the ring. */ char *icalmemory_tmp_copy(const char *str) { - char *b = icalmemory_tmp_buffer(strlen(str) + 1); + char *b; + + if (!str) + return NULL; + + b = icalmemory_tmp_buffer(strlen(str) + 1); + + if (!b) + return NULL; strcpy(b, str); @@ -250,7 +248,67 @@ char *icalmemory_tmp_copy(const char *str) char *icalmemory_strdup(const char *s) { - return strdup(s); + size_t l; + char *res; + + if (!s) + return NULL; + + l = (strlen(s) + 1) * sizeof(char); + res = (char *) icalmemory_new_buffer(l); + if (res == NULL) + return NULL; + + memcpy(res, s, l); + + return res; +} + +#if defined(MEMORY_CONSISTENCY) +static icalmemory_malloc_f global_icalmem_malloc = &test_malloc; +#elif defined(ICALMEMORY_DEFAULT_MALLOC) && !defined(S_SPLINT_S) +static icalmemory_malloc_f global_icalmem_malloc = &ICALMEMORY_DEFAULT_MALLOC; +#else +static icalmemory_malloc_f global_icalmem_malloc = NULL; +#endif + +#if defined(MEMORY_CONSISTENCY) +static icalmemory_realloc_f global_icalmem_realloc = &test_realloc; +#elif defined(ICALMEMORY_DEFAULT_REALLOC) && !defined(S_SPLINT_S) +static icalmemory_realloc_f global_icalmem_realloc = &ICALMEMORY_DEFAULT_REALLOC; +#else +static icalmemory_realloc_f global_icalmem_realloc = NULL; +#endif + +#if defined(MEMORY_CONSISTENCY) +static icalmemory_free_f global_icalmem_free = &test_free; +#elif defined(ICALMEMORY_DEFAULT_FREE) && !defined(S_SPLINT_S) +static icalmemory_free_f global_icalmem_free = &ICALMEMORY_DEFAULT_FREE; +#else +static icalmemory_free_f global_icalmem_free = NULL; +#endif + +void icalmemory_set_mem_alloc_funcs(icalmemory_malloc_f f_malloc, + icalmemory_realloc_f f_realloc, + icalmemory_free_f f_free) +{ + global_icalmem_malloc = f_malloc; + global_icalmem_realloc = f_realloc; + global_icalmem_free = f_free; +} + +void icalmemory_get_mem_alloc_funcs(icalmemory_malloc_f *f_malloc, + icalmemory_realloc_f *f_realloc, + icalmemory_free_f *f_free) { + if (f_malloc) { + *f_malloc = global_icalmem_malloc; + } + if (f_realloc) { + *f_realloc = global_icalmem_realloc; + } + if (f_free) { + *f_free = global_icalmem_free; + } } /* @@ -260,7 +318,14 @@ char *icalmemory_strdup(const char *s) void *icalmemory_new_buffer(size_t size) { - void *b = malloc(size); + void *b; + + if (global_icalmem_malloc == NULL) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + b = global_icalmem_malloc(size); if (b == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); @@ -274,7 +339,14 @@ void *icalmemory_new_buffer(size_t size) void *icalmemory_resize_buffer(void *buf, size_t size) { - void *b = realloc(buf, size); + void *b; + + if (global_icalmem_realloc == NULL) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return 0; + } + + b = global_icalmem_realloc(buf, size); if (b == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); @@ -286,7 +358,12 @@ void *icalmemory_resize_buffer(void *buf, size_t size) void icalmemory_free_buffer(void *buf) { - free(buf); + if (global_icalmem_free == NULL) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return; + } + + global_icalmem_free(buf); } void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const char *string) @@ -314,7 +391,11 @@ void icalmemory_append_string(char **buf, char **pos, size_t *buf_size, const ch *buf_size = (*buf_size) * 2 + final_length; - new_buf = realloc(*buf, *buf_size); + new_buf = icalmemory_resize_buffer(*buf, *buf_size); + if (!new_buf) { + // an error was set in the resize function, so we just return here. + return; + } new_pos = (void *)((size_t) new_buf + data_length); @@ -351,7 +432,11 @@ void icalmemory_append_char(char **buf, char **pos, size_t *buf_size, char ch) *buf_size = (*buf_size) * 2 + final_length + 1; - new_buf = realloc(*buf, *buf_size); + new_buf = icalmemory_resize_buffer(*buf, *buf_size); + if (!new_buf) { + // an error was set in the resize function, so we just return here. + return; + } new_pos = (void *)((size_t) new_buf + data_length); diff --git a/src/libical/icalmemory.h b/src/libical/icalmemory.h index 7eb7e010..39541d2d 100644 --- a/src/libical/icalmemory.h +++ b/src/libical/icalmemory.h @@ -2,18 +2,9 @@ FILE: icalmemory.h CREATOR: eric 30 June 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ @@ -50,7 +41,7 @@ * @return A pointer to the newly created buffer on the ring * * Creates a temporary buffer on the ring. Regardless of what @a size you - * specify, the buffer will always be at least ::MIN_BUFFER_SIZE big, and it + * specify, the buffer will always be at least MIN_BUFFER_SIZE big, and it * will be zeroed out. * * @par Error handling @@ -62,7 +53,7 @@ * caller and the returned memory will be automatically reclaimed as more items * are added to the ring buffer. * - * ### Usage + * @par Usage * ```c * char *str = icalmemory_tmp_buffer(256); * strcpy(str, "some data"); @@ -88,7 +79,7 @@ LIBICAL_ICAL_EXPORT void *icalmemory_tmp_buffer(size_t size); * caller, and it will be automatically reclaimed as more items are added to the * buffer. * - * ### Usage + * @par Usage * ```c * const char *str = "Example string"; * char *tmp_copy = icalmemory_tmp_copy(str); @@ -101,9 +92,13 @@ LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str); * @param buf The externally allocated buffer to add to the ring * * Adds an externally allocated buffer to the ring. This ensures that libical - * will `free()` the buffer automatically, either after ::BUFFER_RING_SIZE other + * will `free()` the buffer automatically, either after BUFFER_RING_SIZE other * buffers have been created or added, or after ::icalmemory_free_ring() has - * been called. + * been called. Note that freeing the buffers is done using the + * icalmemory_free_buffer() function, which by default is a wrapper around stdlib's + * free() function. However, if the memory management functions are + * customized by the user, the user must make sure to only pass in buffers + * that have been allocated in a compatible manner. * * @par Error handling * No error is raised if @a buf is `NULL`. @@ -113,7 +108,7 @@ LIBICAL_ICAL_EXPORT char *icalmemory_tmp_copy(const char *str); * be `free()`d manually anymore, it leads to a double-`free()` when icalmemory * reclaims the memory. * - * ### Usage + * @par Usage * ```c * char *buf = calloc(256, sizeof(char)); * @@ -125,11 +120,11 @@ LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf); /** * @brief Frees all memory used in the ring * - * Frees all memory used in the ring. Depending on if ::HAVE_PTHREAD is set or + * Frees all memory used in the ring. Depending on if HAVE_PTHREAD is set or * not, the ring buffer is allocated on a per-thread basis, meaning that if all * rings are to be released, it must be called once in every thread. * - * ### Usage + * @par Usage * ``` c * void *buf = icalmemory_tmp_buffer(256); * @@ -141,9 +136,42 @@ LIBICAL_ICAL_EXPORT void icalmemory_add_tmp_buffer(void *buf); */ LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void); -/* Non-tmp buffers must be freed. These are mostly wrappers around - * malloc, etc, but are used so the caller can change the memory - * allocators in a future version of the library */ +typedef void *(*icalmemory_malloc_f)(size_t); +typedef void *(*icalmemory_realloc_f)(void *, size_t); +typedef void (*icalmemory_free_f)(void *); + +/** + * @brief Configures the functions to use for memory management. + * + * @param f_malloc The function to use for memory allocation. + * @param f_realloc The function to use for memory reallocation. + * @param f_free The function to use for memory deallocation. + * + * This function configures the library to use the specified functions for + * memory management. By default the standard system memory management + * functions malloc(), realloc() and free() are used. + * + * Note: The memory management functions configured via this + * functions are used throughout the core libical component but not within + * other components like libicalvcal. + * @since 3.1.0 + */ +LIBICAL_ICAL_EXPORT void icalmemory_set_mem_alloc_funcs(icalmemory_malloc_f f_malloc, + icalmemory_realloc_f f_realloc, + icalmemory_free_f f_free); + +/** + * @brief Returns the functions used for memory management. + * + * @param f_malloc A pointer to the function to use for memory allocation. + * @param f_realloc A pointer to the function to use for memory reallocation. + * @param f_free A pointer to the function to use for memory deallocation. + * + * Retrieves the functions used by the library for memory management. + * @since 3.1.0 + */ +LIBICAL_ICAL_EXPORT void icalmemory_get_mem_alloc_funcs(icalmemory_malloc_f *f_malloc, + icalmemory_realloc_f *f_realloc, icalmemory_free_f *f_free); /** * @brief Creates new buffer with the specified size. @@ -156,13 +184,16 @@ LIBICAL_ICAL_EXPORT void icalmemory_free_ring(void); * ::ICAL_NEWFAILED_ERROR and returns `NULL`. * * @par Ownership - * Buffers created with this method are owned by the caller. The must be - * released with the appropriate icalmemory_free_buffer() method. + * Buffers created with this method are owned by the caller. They must be + * released with the icalmemory_free_buffer() method. * * This creates a new (non-temporary) buffer of the specified @a size. All * buffers returned by this method are zeroed-out. * - * ### Usage + * By default this function delegates to stdlib's malloc() but + * the used function can be changed via icalmemory_set_mem_alloc_funcs(). + * + * @par Usage * ```c * // create buffer * char *buffer = icalmemory_new_buffer(50); @@ -194,7 +225,10 @@ LIBICAL_ICAL_EXPORT void *icalmemory_new_buffer(size_t size); * appropriate icalmemory_free_buffer() method. The old buffer, @a buf, can not * be used anymore after calling this method. * - * ### Usage + * By default this function delegates to stdlib's realloc() but + * the used function can be configured via icalmemory_set_mem_alloc_funcs(). + * + * @par Usage * ```c * // create new buffer * char *buffer = icalmemory_new_buffer(10); @@ -220,6 +254,9 @@ LIBICAL_ICAL_EXPORT void *icalmemory_resize_buffer(void *buf, size_t size); * @sa icalmemory_new_buffer() * * Releases the memory of the buffer. + * + * By default this function delegates to stdlib's free() but + * the used function can be configured via icalmemory_set_mem_alloc_funcs(). */ LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf); @@ -249,7 +286,7 @@ LIBICAL_ICAL_EXPORT void icalmemory_free_buffer(void *buf); * size of @a buf and will be changed if @a buf is reallocated. @a pos will * point to the last byte of the new string in @a buf, usually a `'\0'` * - * ### Example + * @par Example * ```c * // creates a new buffer * int buffer_len = 15; @@ -291,7 +328,7 @@ LIBICAL_ICAL_EXPORT void icalmemory_append_string(char **buf, char **pos, size_t * reallocated. @a pos will point to the new terminating `'\0'` character @a * buf. * - * ### Example + * @par Example * ```c * // creates a new buffer * int buffer_len = 15; @@ -323,17 +360,19 @@ LIBICAL_ICAL_EXPORT void icalmemory_append_char(char **buf, char **pos, size_t * * * @par Ownership * The returned string is owned by the caller and needs to be released with the - * appropriate `free()` method. + * `icalmemory_free_buffer()` method. * - * A wrapper around `strdup()`. Partly to trap calls to `strdup()`, partly - * because in `-ansi`, `gcc` on Red Hat claims that `strdup()` is undeclared. + * Replaces `strdup()`. The function uses icalmemory_new_buffer() for memory + * allocation. It also helps trapping calls to `strdup()` and solves the + * problem that in `-ansi`, `gcc` on Red Hat claims that `strdup()` is + * undeclared. * - * ### Usage + * @par Usage * ```c * const char *my_str = "LibIcal"; * char *dup = icalmemory_strdup(my_str); * printf("%s\n", dup); - * free(dup); + * icalmemory_free_buffer(dup); * ``` */ LIBICAL_ICAL_EXPORT char *icalmemory_strdup(const char *s); diff --git a/src/libical/icalmime.c b/src/libical/icalmime.c index 37688d0f..d1345e31 100644 --- a/src/libical/icalmime.c +++ b/src/libical/icalmime.c @@ -2,18 +2,10 @@ FILE: icalmime.c CREATOR: eric 26 July 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ @@ -49,7 +41,7 @@ static void *icalmime_text_new_part(void) struct text_part *impl; - if ((impl = (struct text_part *)malloc(sizeof(struct text_part))) == 0) { + if ((impl = (struct text_part *)icalmemory_new_buffer(sizeof(struct text_part))) == 0) { return 0; } @@ -77,7 +69,7 @@ static void *icalmime_textcalendar_end_part(void *part) icalcomponent *c = icalparser_parse_string(impl->buf); icalmemory_free_buffer(impl->buf); - free(impl); + icalmemory_free_buffer(impl); return c; } @@ -88,7 +80,7 @@ static void *icalmime_text_end_part_r(void *part) struct text_part *impl = (struct text_part *)part; buf = impl->buf; - free(impl); + icalmemory_free_buffer(impl); return buf; } @@ -166,7 +158,7 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d int i, last_level = 0; icalcomponent *root = 0, *parent = 0, *comp = 0, *last = 0; - if ((parts = (struct sspm_part *)malloc(NUM_PARTS * sizeof(struct sspm_part))) == 0) { + if ((parts = (struct sspm_part *)icalmemory_new_buffer(NUM_PARTS * sizeof(struct sspm_part))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -185,7 +177,7 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d const char *minor = sspm_minor_type_string(parts[i].header.minor); if (parts[i].header.minor == SSPM_UNKNOWN_MINOR_TYPE) { - assert(parts[i].header.minor_text != 0); + icalassert(parts[i].header.minor_text != 0); minor = parts[i].header.minor_text; } @@ -195,7 +187,7 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d if (comp == 0) { /* HACK Handle Error */ - assert(0); + icalassert(0); } if (parts[i].header.error != SSPM_NO_ERROR) { @@ -245,7 +237,7 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d icalcomponent_add_property( comp, icalproperty_new_xlicmimecontenttype(mimeTypeCopy)); - free(mimeTypeCopy); + icalmemory_free_buffer(mimeTypeCopy); } if (parts[i].header.encoding != SSPM_NO_ENCODING) { @@ -288,7 +280,7 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d icalcomponent_add_property( comp, icalproperty_new_description(descStr)); - free(descStr); + icalmemory_free_buffer(descStr); parts[i].data = 0; } @@ -322,16 +314,16 @@ icalcomponent *icalmime_parse(char *(*get_string) (char *s, size_t size, void *d icalcomponent_add_component(parent, comp); } else { - assert(0); + icalassert(0); } last = comp; last_level = parts[i].level; - assert(parts[i].data == 0); + icalassert(parts[i].data == 0); } sspm_free_parts(parts, NUM_PARTS); - free(parts); + icalmemory_free_buffer(parts); return root; } @@ -342,7 +334,7 @@ int icalmime_test(char *(*get_string) (char *s, size_t size, void *d), void *dat struct sspm_part *parts; int i; - if ((parts = (struct sspm_part *)malloc(NUM_PARTS * sizeof(struct sspm_part))) == 0) { + if ((parts = (struct sspm_part *)icalmemory_new_buffer(NUM_PARTS * sizeof(struct sspm_part))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -363,7 +355,7 @@ int icalmime_test(char *(*get_string) (char *s, size_t size, void *d), void *dat sspm_write_mime(parts, NUM_PARTS, &out, "To: bob@bob.org"); printf("%s\n", out); - free(out); + icalmemory_free_buffer(out); return 0; } diff --git a/src/libical/icalmime.h b/src/libical/icalmime.h index ea2e1a0d..8dca137c 100644 --- a/src/libical/icalmime.h +++ b/src/libical/icalmime.h @@ -2,18 +2,10 @@ FILE: icalmime.h CREATOR: eric 26 July 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALMIME_H diff --git a/src/libical/icalparameter.c b/src/libical/icalparameter.c index 0856b3c2..e4bf5842 100644 --- a/src/libical/icalparameter.c +++ b/src/libical/icalparameter.c @@ -2,18 +2,9 @@ FILE: icalderivedparameters.{c,h} CREATOR: eric 09 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalderivedparameters.{c,h} @@ -36,7 +27,7 @@ LIBICAL_ICAL_EXPORT struct icalparameter_impl *icalparameter_new_impl(icalparame { struct icalparameter_impl *v; - if ((v = (struct icalparameter_impl *)malloc(sizeof(struct icalparameter_impl))) == 0) { + if ((v = (struct icalparameter_impl *)icalmemory_new_buffer(sizeof(struct icalparameter_impl))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -67,18 +58,18 @@ void icalparameter_free(icalparameter *param) } if (param->string != 0) { - free((void *)param->string); + icalmemory_free_buffer((void *)param->string); } if (param->x_name != 0) { - free((void *)param->x_name); + icalmemory_free_buffer((void *)param->x_name); } memset(param, 0, sizeof(icalparameter)); param->parent = 0; param->id[0] = 'X'; - free(param); + icalmemory_free_buffer(param); } icalparameter *icalparameter_clone(const icalparameter *old) @@ -141,7 +132,7 @@ icalparameter *icalparameter_new_from_string(const char *str) if (eq == 0) { icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(cpy); + icalmemory_free_buffer(cpy); return 0; } @@ -153,7 +144,7 @@ icalparameter *icalparameter_new_from_string(const char *str) if (kind == ICAL_NO_PARAMETER) { icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(cpy); + icalmemory_free_buffer(cpy); return 0; } @@ -165,7 +156,7 @@ icalparameter *icalparameter_new_from_string(const char *str) icalparameter_set_iana_name(param, cpy); } - free(cpy); + icalmemory_free_buffer(cpy); return param; } @@ -297,7 +288,7 @@ char *icalparameter_as_ical_string_r(icalparameter *param) if (param->kind == ICAL_NO_PARAMETER || param->kind == ICAL_ANY_PARAMETER || kind_string == 0) { icalerror_set_errno(ICAL_BADARG_ERROR); - free(buf); + icalmemory_free_buffer(buf); return 0; } @@ -315,7 +306,7 @@ char *icalparameter_as_ical_string_r(icalparameter *param) icalmemory_append_string(&buf, &buf_ptr, &buf_size, str); } else { icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(buf); + icalmemory_free_buffer(buf); return 0; } @@ -352,7 +343,7 @@ void icalparameter_set_xname(icalparameter *param, const char *v) icalerror_check_arg_rv((v != 0), "v"); if (param->x_name != 0) { - free((void *)param->x_name); + icalmemory_free_buffer((void *)param->x_name); } param->x_name = icalmemory_strdup(v); @@ -375,7 +366,7 @@ void icalparameter_set_xvalue(icalparameter *param, const char *v) icalerror_check_arg_rv((v != 0), "v"); if (param->string != 0) { - free((void *)param->string); + icalmemory_free_buffer((void *)param->string); } param->string = icalmemory_strdup(v); diff --git a/src/libical/icalparameter.h b/src/libical/icalparameter.h index 8bbc96bc..93cd4855 100644 --- a/src/libical/icalparameter.h +++ b/src/libical/icalparameter.h @@ -2,18 +2,10 @@ FILE: icalparam.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /** @@ -34,9 +26,9 @@ /*typedef struct icalparameter_impl icalparameter;*/ /** - * @brief Creates new ::icalparameter object. - * @param kind The kind of ::icalparameter to create. - * @return An ::icalparameter with the given kind. + * @brief Creates new icalparameter object. + * @param kind The kind of icalparameter to create. + * @return An icalparameter with the given kind. * * @par Error handling * If there was an internal error regarding @@ -47,7 +39,7 @@ * Objects created by this method are owned by the caller and * must be released with the icalparameter_free() method. * - * ### Usage + * @par Usage * ```c * // create new parameter * icalparameter *parameter = icalparameter_new(); @@ -63,9 +55,9 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new(icalparameter_kind kind); /** - * @brief Creates new ::icalparameter as a clone of the given one. + * @brief Creates new icalparameter as a clone of the given one. * @param p The existing, non-`NULL` parameter to clone. - * @return An ::icalparameter that is a clone of the given one. + * @return An icalparameter that is a clone of the given one. * * @par Error handling * If @a p is `NULL`, it returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR. @@ -76,7 +68,7 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new(icalparameter_kind kind); * Objects created by this method are owned by the caller and * must be released with the icalparameter_free() method. * - * ### Usage + * @par Usage * ```x * // create an icalparameter * icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR"); @@ -103,9 +95,9 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_clone(const icalparameter *p); LIBICAL_ICAL_EXPORT LIBICAL_DEPRECATED(icalparameter *icalparameter_new_clone(icalparameter *p)); /** - * @brief Creates new ::icalparameter object from string - * @param value The string from which to create the ::icalparameter, in the form `"PARAMNAME=VALUE"` - * @return An ::icalparameter that corresponds to the given string. + * @brief Creates new icalparameter object from string + * @param value The string from which to create the icalparameter, in the form `"PARAMNAME=VALUE"` + * @return An icalparameter that corresponds to the given string. * * @par Error handling * If there was an internal error copying data, it returns `NULL` and sets @@ -117,7 +109,7 @@ LIBICAL_ICAL_EXPORT LIBICAL_DEPRECATED(icalparameter *icalparameter_new_clone(ic * Objects created by this method are owned by the caller and * must be released with the icalparameter_free() method. * - * ### Usage + * @par Usage * ```c * icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR"); * @@ -131,10 +123,10 @@ LIBICAL_ICAL_EXPORT LIBICAL_DEPRECATED(icalparameter *icalparameter_new_clone(ic LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new_from_string(const char *value); /** - * @brief Creates new ::icalparameter of a given @a kind with a given @a value - * @param kind The kind of ::icalparameter to create + * @brief Creates new icalparameter of a given @a kind with a given @a value + * @param kind The kind of icalparameter to create * @param value The value of the parameter - * @return An ::icalparameter with the given kind and value. + * @return An icalparameter with the given kind and value. * * @par Error handling * If value is `NULL`, it returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR. @@ -143,7 +135,7 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new_from_string(const char *val * Objects created by this method are owned by the caller and * must be released with the icalparameter_free() method. * - * ### Example + * @par Example * ```c * // create new parameter * icalparameter *param; @@ -161,7 +153,7 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new_from_value_string(icalparam const char *value); /** - * @brief Frees an ::icalparameter object. + * @brief Frees an icalparameter object. * @param parameter The icalparameter to free * * This method needs to be used on all parameter objects returned @@ -170,7 +162,7 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new_from_value_string(icalparam * and on cloned parameter objects returned by icalparameter_clone() * when these object are not needed anymore and to be released. * - * ### Usage + * @par Usage * ```c * icalparameter *param = icalparameter_new(); * @@ -185,8 +177,8 @@ LIBICAL_ICAL_EXPORT icalparameter *icalparameter_new_from_value_string(icalparam LIBICAL_ICAL_EXPORT void icalparameter_free(icalparameter *parameter); /** - * @brief Converts ::icalparameter into a string representation - * @param parameter The ::icalparameter to convert + * @brief Converts icalparameter into a string representation + * @param parameter The icalparameter to convert * @return A string representing the parameter according to RFC5445/RFC6868. * @sa icalparameter_as_ical_string_r() * @@ -203,7 +195,7 @@ LIBICAL_ICAL_EXPORT void icalparameter_free(icalparameter *parameter); * the library. A version of this function, which returns strings * that are not owned by libical, is icalparameter_as_ical_string_r(). * - * ### Usage + * @par Usage * ```c * icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR"); * @@ -217,8 +209,8 @@ LIBICAL_ICAL_EXPORT void icalparameter_free(icalparameter *parameter); LIBICAL_ICAL_EXPORT char *icalparameter_as_ical_string(icalparameter *parameter); /** - * @brief Converts ::icalparameter into an string representation according to RFC5445/RFC6868. - * @param parameter The ::icalparameter to convert + * @brief Converts icalparameter into an string representation according to RFC5445/RFC6868. + * @param parameter The icalparameter to convert * @return A string representing the parameter * @sa icalparameter_as_ical_string() * @@ -231,18 +223,18 @@ LIBICAL_ICAL_EXPORT char *icalparameter_as_ical_string(icalparameter *parameter) * * @par Ownership * Strings returned by this method are owned by the caller, thus they need - * to be manually `free()`d after use. A version of this function which returns - * strings that do not need to be freed manually is - * icalparameter_as_ical_string(). + * to be manually `icalmemory_free_buffer()`d after use. + * A version of this function which returns strings that do not + * need to be freed manually is icalparameter_as_ical_string(). * - * ### Usage + * @par Usage * ```c * icalparameter *param = icalparameter_new_from_string("ROLE=CHAIR"); * * if(param) { * char *str = icalparameter_as_ical_string(param); * printf("%s\n", str); - * free(str); + * icalmemory_free_buffer(str); * } * * icalparameter_free(param); @@ -302,19 +294,19 @@ LIBICAL_ICAL_EXPORT int icalparameter_isa_parameter(void *param); /** * @brief Sets the X-name of @a param to @a v - * @param param The ::icalparameter to change + * @param param The icalparameter to change * @param v The X-name to set @a param to * @sa icalparameter_get_xname() * * @par Error handling - * If either @a param or @a v are `NULL`, it sets ::icalerrno to ::ICAL_BARARG_ERROR. + * If either @a param or @a v are `NULL`, it sets ::icalerrno to ICAL_BARARG_ERROR. * If there is an error acquiring memory, it sets `errno` to `ENOMEM`. * * @par Ownership * The passed string @a v stays in the ownership of the caller - libical * creates a copy of it. * - * ### Usage + * @par Usage * ```c * // creates new parameter * icalparameter *param = icalparameter_new(); @@ -332,19 +324,19 @@ LIBICAL_ICAL_EXPORT void icalparameter_set_xname(icalparameter *param, const cha /** * @brief Returns the X-name of @a param - * @param param The ::icalparameter whose X-name is to be returned + * @param param The icalparameter whose X-name is to be returned * @return A string representing the X-name of @a param * @sa icalparameter_set_xname() * * @par Error handling * Returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR when a `NULL` - * is passed instead of an ::icalparameter. + * is passed instead of an icalparameter. * * @par Ownership * The string that is returned stays owned by libical and must not * be freed by the caller. * - * ### Usage + * @par Usage * ```c * // creates new parameter * icalparameter *param = icalparameter_new(); @@ -362,19 +354,19 @@ LIBICAL_ICAL_EXPORT const char *icalparameter_get_xname(icalparameter *param); /** * @brief Sets the X-value of @a param to @a v - * @param param The ::icalparameter to change + * @param param The icalparameter to change * @param v The X-value to set @a param to * @sa icalparameter_get_xvalue() * * @par Error handling - * If either @a param or @a v are `NULL`, it sets ::icalerrno to ::ICAL_BARARG_ERROR. + * If either @a param or @a v are `NULL`, it sets ::icalerrno to ICAL_BARARG_ERROR. * If there is an error acquiring memory, it sets `errno` to `ENOMEM`. * * @par Ownership * The passed string @a v stays in the ownership of the caller - libical * creates a copy of it. * - * ### Usage + * @par Usage * ```c * // create new parameter * icalparameter *param = icalparameter_new_from_string("X-TEST=FAIL"); @@ -393,19 +385,19 @@ LIBICAL_ICAL_EXPORT void icalparameter_set_xvalue(icalparameter *param, const ch /** * @brief Returns the X-value of @a param - * @param param The ::icalparameter whose X-value is to be returned + * @param param The icalparameter whose X-value is to be returned * @return A string representing the X-value of @a param * @sa icalparameter_set_xvalue() * * @par Error handling * Returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR when a `NULL` - * is passed instead of an ::icalparameter. + * is passed instead of an icalparameter. * * @par Ownership * The string that is returned stays owned by libical and must not * be freed by the caller. * - * ### Usage + * @par Usage * ```c * // create new parameter * icalparameter *param = icalparameter_new_from_string("X-TEST=FAIL"); @@ -431,14 +423,14 @@ LIBICAL_ICAL_EXPORT const char *icalparameter_get_xvalue(icalparameter *param); * @sa icalparameter_get_iana_name() * * @par Error handling - * If either @a param or @a v are `NULL`, it sets ::icalerrno to ::ICAL_BARARG_ERROR. + * If either @a param or @a v are `NULL`, it sets :calerrno to ICAL_BARARG_ERROR. * If there is an error acquiring memory, it sets `errno` to `ENOMEM`. * * @par Ownership * The passed string @a v stays in the ownership of the caller - libical * creates a copy of it. * - * ### Usage + * @par Usage * ```c * // creates new parameter * icalparameter *param = icalparameter_new(); @@ -456,19 +448,19 @@ LIBICAL_ICAL_EXPORT void icalparameter_set_iana_name(icalparameter *param, const /** * @brief Returns the IANA name of @a param - * @param param The ::icalparameter whose IANA name is to be returned + * @param param The icalparameter whose IANA name is to be returned * @return A string representing the IANA name of @a param * @sa icalparameter_set_iana_name() * * @par Error handling * Returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR when a `NULL` - * is passed instead of an ::icalparameter. + * is passed instead of an icalparameter. * * @par Ownership * The string that is returned stays owned by libical and must not * be freed by the caller. * - * ### Usage + * @par Usage * ```c * // creates new parameter * icalparameter *param = icalparameter_new(); @@ -486,19 +478,19 @@ LIBICAL_ICAL_EXPORT const char *icalparameter_get_iana_name(icalparameter *param /** * @brief Sets the IANA value of @a param to @a v - * @param param The ::icalparameter to change + * @param param The icalparameter to change * @param v The IANA value to set @a param to * @sa icalparameter_get_iana_value() * * @par Error handling - * If either @a param or @a v are `NULL`, it sets ::icalerrno to ::ICAL_BARARG_ERROR. + * If either @a param or @a v are `NULL`, it sets ::icalerrno to ICAL_BARARG_ERROR. * If there is an error acquiring memory, it sets `errno` to `ENOMEM`. * * @par Ownership * The passed string @a v stays in the ownership of the caller - libical * creates a copy of it. * - * ### Usage + * @par Usage * ```c * // create new parameter * icalparameter *param = icalparameter_new_from_string("ROLE=ATTENDEE"); @@ -517,19 +509,19 @@ LIBICAL_ICAL_EXPORT void icalparameter_set_iana_value(icalparameter *param, cons /** * @brief Returns the IANA value of @a param - * @param param The ::icalparameter whose value is to be returned + * @param param The icalparameter whose value is to be returned * @return A string representing the value of @a param * @sa icalparameter_set_iana_value() * * @par Error handling * Returns `NULL` and sets ::icalerrno to ::ICAL_BADARG_ERROR when a `NULL` - * is passed instead of an ::icalparameter. + * is passed instead of an icalparameter. * * @par Ownership * The string that is returned stays owned by libical and must not * be freed by the caller. * - * ### Usage + * @par Usage * ```c * // create new parameter * icalparameter *param = icalparameter_new_from_string("ROLE=ATTENDEE"); @@ -557,9 +549,9 @@ LIBICAL_ICAL_EXPORT const char *icalparameter_get_iana_value(icalparameter *para * ::icalerrno to ::ICAL_BADARG_ERROR. * * @par Ownership - * Does not take ownership of either ::icalparameter. + * Does not take ownership of either icalparameter. * - * ### Example + * @par Example * ```c * // create two parameters * icalparameter *param1 = icalparameter_new_from_string("ROLE=CHAIR"); @@ -578,18 +570,18 @@ LIBICAL_ICAL_EXPORT int icalparameter_has_same_name(icalparameter *param1, icalp /* Convert enumerations */ /** - * @brief Returns a string representing the given ::icalparameter_kind + * @brief Returns a string representing the given icalparameter_kind * @param kind The icalparameter_kind * @return A string representing @a kind * * @par Error handling - * When passed a non-existing ::icalparameter_kind, it returns `NULL`. + * When passed a non-existing icalparameter_kind, it returns `NULL`. * * @par Ownership * The string that is returned by this function is owned by libical and * must not be freed by the caller. * - * ### Usage + * @par Usage * ```c * assert(0 == strcmp(icalparameter_kind_to_string(ICAL_ROLE_PARAMETER), "ROLE")); * assert(0 == strcmp(icalparameter_kind_to_string(ICAL_EMAIL_PARAMETER), "EMAIL)); @@ -599,20 +591,20 @@ LIBICAL_ICAL_EXPORT int icalparameter_has_same_name(icalparameter *param1, icalp LIBICAL_ICAL_EXPORT const char *icalparameter_kind_to_string(icalparameter_kind kind); /** - * @brief Returns the ::icalparameter_kind for a given string + * @brief Returns the icalparameter_kind for a given string * @param string A string describing an icalparameter_kind * @return An icalparameter_kind * * @par Error handling - * Returns ::ICAL_NO_PARAMETER if @a string is `NULL`. + * Returns ICAL_NO_PARAMETER if @a string is `NULL`. * If it can't find the parameter, depending on * the ical_get_unknown_token_handling_setting(), it returns either - * ::ICAL_NO_PARAMETER or ::ICAL_IANA_PARAMETER. + * ICAL_NO_PARAMETER or ICAL_IANA_PARAMETER. * * @par Ownership * Does not take ownership of @a string. * - * ### Usage + * @par Usage * ```c * assert(icalparameter_string_to_kind("ROLE") == ICAL_ROLE_PARAMETER); * assert(icalparameter_string_to_kind("EMAIL") == ICAL_EMAIL_PARAMETER); @@ -622,11 +614,11 @@ LIBICAL_ICAL_EXPORT const char *icalparameter_kind_to_string(icalparameter_kind LIBICAL_ICAL_EXPORT icalparameter_kind icalparameter_string_to_kind(const char *string); /** - * @brief Checks the validity of a ::icalparameter_kind + * @brief Checks the validity of a icalparameter_kind * @param kind The icalparameter_kind * @return 1 if @a kind is valid, 0 otherwise * - * ### Usage + * @par Usage * ```c * assert(icalparameter_kind_is_valid(ICAL_ROLE_PARAMETER)); * ``` diff --git a/src/libical/icalparameter_cxx.cpp b/src/libical/icalparameter_cxx.cpp index 6b26a454..70510533 100644 --- a/src/libical/icalparameter_cxx.cpp +++ b/src/libical/icalparameter_cxx.cpp @@ -3,18 +3,10 @@ * @author fnguyen (12/10/01) * @brief Implementation of C++ Wrapper for icalparameter.c * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #include "icalparameter_cxx.h" diff --git a/src/libical/icalparameter_cxx.h b/src/libical/icalparameter_cxx.h index 81c4d9e6..dfe98bbc 100644 --- a/src/libical/icalparameter_cxx.h +++ b/src/libical/icalparameter_cxx.h @@ -3,18 +3,10 @@ * @author fnguyen (12/10/01) * @brief Definition of C++ Wrapper for icalparameter.c * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #ifndef ICALPARAMETER_CXX_H diff --git a/src/libical/icalparameterimpl.h b/src/libical/icalparameterimpl.h index 0d710978..67b4c76f 100644 --- a/src/libical/icalparameterimpl.h +++ b/src/libical/icalparameterimpl.h @@ -2,18 +2,9 @@ FILE: icalparameterimpl.h CREATOR: eric 09 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalderivedparameters.{c,h} diff --git a/src/libical/icalparser.c b/src/libical/icalparser.c index 4ab1b1ca..3aaba0c8 100644 --- a/src/libical/icalparser.c +++ b/src/libical/icalparser.c @@ -2,31 +2,11 @@ FILE: icalparser.c CREATOR: eric 04 August 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ - - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom + The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -102,7 +82,7 @@ icalparser *icalparser_new(void) { struct icalparser_impl *impl = 0; - if ((impl = (struct icalparser_impl *)malloc(sizeof(struct icalparser_impl))) == 0) { + if ((impl = (struct icalparser_impl *)icalmemory_new_buffer(sizeof(struct icalparser_impl))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -135,7 +115,7 @@ void icalparser_free(icalparser *parser) pvl_free(parser->components); - free(parser); + icalmemory_free_buffer(parser); } void icalparser_set_gen_data(icalparser *parser, void *data) @@ -323,7 +303,7 @@ static char *parser_get_param_name_heap(char *line, char **end) *end = *end + 1; next = (**end == '"') ? *end : parser_get_next_char('"', *end, 0); if (next == 0) { - free(str); + icalmemory_free_buffer(str); *end = NULL; return 0; } @@ -557,7 +537,7 @@ char *icalparser_get_line(icalparser *parser, } else { /* No data in output; return and signal that there is no more input */ - free(line); + icalmemory_free_buffer(line); return 0; } } @@ -661,8 +641,8 @@ icalcomponent *icalparser_parse(icalparser *parser, /* This is bad news... assert? */ } - assert(parser->root_component == 0); - assert(pvl_count(parser->components) == 0); + icalassert(parser->root_component == 0); + icalassert(pvl_count(parser->components) == 0); if (root == 0) { /* Just one component */ @@ -682,7 +662,7 @@ icalcomponent *icalparser_parse(icalparser *parser, } else { /* Badness */ - assert(0); + icalassert(0); } c = 0; @@ -820,7 +800,7 @@ icalcomponent *icalparser_add_line(icalparser *parser, char *line) (void)icalparser_clean(parser); /* may reset parser->root_component */ } - assert(pvl_count(parser->components) == 0); + icalassert(pvl_count(parser->components) == 0); parser->state = ICALPARSER_SUCCESS; rtrn = parser->root_component; @@ -1247,7 +1227,7 @@ icalcomponent *icalparser_add_line(icalparser *parser, char *line) if (pvl_data(pvl_tail(parser->components)) == 0 && parser->level == 0) { /* HACK. Does this clause ever get executed? */ parser->state = ICALPARSER_SUCCESS; - assert(0); + icalassert(0); return parser->root_component; } else { parser->state = ICALPARSER_IN_PROGRESS; @@ -1365,6 +1345,9 @@ icalcomponent *icalparser_parse_string(const char *str) d.str = str; p = icalparser_new(); + if (!p) + return NULL; + icalparser_set_gen_data(p, &d); icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR, ICAL_ERROR_NONFATAL); diff --git a/src/libical/icalparser.h b/src/libical/icalparser.h index 765f7730..e8dfb6a9 100644 --- a/src/libical/icalparser.h +++ b/src/libical/icalparser.h @@ -2,18 +2,9 @@ FILE: icalparser.h CREATOR: eric 20 April 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalparser.h ======================================================================*/ @@ -31,7 +22,7 @@ * This file provides methods to parse iCalendar-formatted data * into the structures provided by this library. * - * ### Usage + * @par Usage * Create a new parser via icalparser_new_parser(), then add lines one at * a time with icalparser_add_line(). icalparser_add_line() will return * non-zero when it has finished with a component. @@ -73,18 +64,18 @@ typedef enum icalparser_state typedef char *(*icalparser_line_gen_func) (char *s, size_t size, void *d); /** - * @brief Creates a new ::icalparser. - * @return An ::icalparser object + * @brief Creates a new icalparser. + * @return An icalparser object * * @par Error handling * On error, it returns `NULL` and sets ::icalerrno to * ::ICAL_NEWFAILED_ERROR. * * @par Ownership - * All ::icalparser objects created with this function need to be + * All icalparser objects created with this function need to be * freed using the icalparser_free() function. * - * ### Usage + * @par Usage * ```c * // create new parser * icalparser *parser = icalparser_new(); @@ -98,7 +89,7 @@ typedef char *(*icalparser_line_gen_func) (char *s, size_t size, void *d); LIBICAL_ICAL_EXPORT icalparser *icalparser_new(void); /** - * @brief Adds a single line to be parsed by the ::icalparser. + * @brief Adds a single line to be parsed by the icalparser. * @param parser The parser to use * @param str A string representing a single line of RFC5545-formatted iCalendar data * @return When this was the last line of the component to be parsed, @@ -112,15 +103,15 @@ LIBICAL_ICAL_EXPORT icalparser *icalparser_new(void); * - If @a line is `NULL`, it returns `NULL` and sets the @a parser's ::icalparser_state to * ::ICALPARSER_ERROR. * - For errors during parsing, the functions can set the ::icalparser_state to - * ::ICALPARSER_ERROR and/or return components of the type ::ICAL_XLICINVALID_COMPONENT, - * or components with properties of the type ::ICAL_XLICERROR_PROPERTY. + * ::ICALPARSER_ERROR and/or return components of the type ICAL_XLICINVALID_COMPONENT, + * or components with properties of the type ICAL_XLICERROR_PROPERTY. * * @par Ownership * Ownership of the @a str is transferred to libical upon calling this - * method. The returned ::icalcomponent is owned by the caller and needs + * method. The returned icalcomponent is owned by the caller and needs * to be `free()`d with the appropriate method after it's no longer needed. * - * ### Example + * @par Example * ```c * char* read_stream(char *s, size_t size, void *d) * { @@ -159,9 +150,9 @@ LIBICAL_ICAL_EXPORT icalparser *icalparser_new(void); LIBICAL_ICAL_EXPORT icalcomponent *icalparser_add_line(icalparser *parser, char *str); /** - * @brief Cleans out an ::icalparser and returns whatever it has parsed so far. - * @param parser The ::icalparser to clean - * @return The parsed ::icalcomponent + * @brief Cleans out an icalparser and returns whatever it has parsed so far. + * @param parser The icalparser to clean + * @return The parsed icalcomponent * * @par Error handling * If @a parser is `NULL`, it returns `NULL` and sets ::icalerrno to @@ -169,7 +160,7 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalparser_add_line(icalparser *parser, char * property into the affected components. * * @par Ownership - * The returned ::icalcomponent is property of the caller and needs to be + * The returned icalcomponent is property of the caller and needs to be * free'd with icalcomponent_free() after use. * * This will parse components even if it hasn't encountered a proper @@ -184,7 +175,7 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalparser_clean(icalparser *parser); * @param parser The (valid, non-`NULL`) parser object * @return The current state of the icalparser, as an ::icalparser_state * - * ### Example + * @par Example * ```c * icalparser *parser = icalparser_new(); * @@ -202,10 +193,10 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalparser_clean(icalparser *parser); LIBICAL_ICAL_EXPORT icalparser_state icalparser_get_state(icalparser *parser); /** - * @brief Frees an ::icalparser object. - * @param parser The ::icalparser to be freed. + * @brief Frees an icalparser object. + * @param parser The icalparser to be freed. * - * ### Example + * @par Example * ```c * icalparser *parser = icalparser_new(); * @@ -232,14 +223,14 @@ LIBICAL_ICAL_EXPORT void icalparser_free(icalparser *parser); * - If data read by @a line_gen_func is `NULL`, it returns `NULL` * and sets the @a parser's ::icalparser_state to ::ICALPARSER_ERROR. * - For errors during parsing, the functions can set the ::icalparser_state to - * ::ICALPARSER_ERROR and/or return components of the type ::ICAL_XLICINVALID_COMPONENT, - * or components with properties of the type ::ICAL_XLICERROR_PROPERTY. + * ::ICALPARSER_ERROR and/or return components of the type ICAL_XLICINVALID_COMPONENT, + * or components with properties of the type ICAL_XLICERROR_PROPERTY. * * @par Ownership - * The returned ::icalcomponent is owned by the caller of the function, and + * The returned icalcomponent is owned by the caller of the function, and * needs to be `free()`d with the appropriate method when no longer needed. * - * ### Example + * @par Example * ```c * char* read_stream(char *s, size_t size, void *d) * { @@ -284,18 +275,18 @@ LIBICAL_ICAL_EXPORT icalcomponent *icalparser_parse(icalparser *parser, LIBICAL_ICAL_EXPORT void icalparser_set_gen_data(icalparser *parser, void *data); /** - * @brief Parses a string and returns the parsed ::icalcomponent. + * @brief Parses a string and returns the parsed icalcomponent. * @param str The iCal formatted data to be parsed - * @return An ::icalcomponent representing the iCalendar + * @return An icalcomponent representing the iCalendar * * @par Error handling * On error, returns `NULL` and sets ::icalerrno * * @par Ownership - * The returned ::icalcomponent is owned by the caller of the function, and + * The returned icalcomponent is owned by the caller of the function, and * needs to be free'd with the appropriate functions after use. * - * ### Example + * @par Example * ```c * char *ical_string; * diff --git a/src/libical/icalperiod.c b/src/libical/icalperiod.c index 0dc3cb01..f3e57aab 100644 --- a/src/libical/icalperiod.c +++ b/src/libical/icalperiod.c @@ -2,18 +2,9 @@ FILE: icalperiod.c CREATOR: eric 02 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libical/icalperiod.h b/src/libical/icalperiod.h index fb8e3140..410a3bc4 100644 --- a/src/libical/icalperiod.h +++ b/src/libical/icalperiod.h @@ -2,18 +2,9 @@ FILE: icalperiod.h CREATOR: eric 26 Jan 2001 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -57,7 +48,7 @@ struct icalperiodtype * If @a str is not properly formatted, it sets ::icalerrno to * ::ICAL_MALFORMEDDATA_ERROR and returns icalperiodtype_null_period(). * - * ### Data format + * @par Data format * There are two ways to specify a duration; either a start time * and an end time can be specified, or a start time and a duration. * The format for there is as such: @@ -68,7 +59,7 @@ struct icalperiodtype * icaltime_from_string(), and the format for the duration * is the same as that used by icaldurationtype_from_string(). * - * ### Usage + * @par Usage * ```c * // create icalperiodtype * const char *period_string = "20170606T090000/20170607T090000"; @@ -94,7 +85,7 @@ LIBICAL_ICAL_EXPORT struct icalperiodtype icalperiodtype_from_string(const char * The string returned by this method is owned by libical and must not be * `free()` by the caller. * - * ### Example + * @par Example * ```c * // create icalperiodtype * const char *period_string = "20170606T090000/20170607T090000"; @@ -120,7 +111,7 @@ LIBICAL_ICAL_EXPORT const char *icalperiodtype_as_ical_string(struct icalperiodt * The string returned by this method is owned by the caller and must be * released with the appropriate function after use. * - * ### Example + * @par Example * ```c * // create icalperiodtype * const char *period_string = "20170606T090000/20170607T090000"; @@ -139,7 +130,7 @@ LIBICAL_ICAL_EXPORT char *icalperiodtype_as_ical_string_r(struct icalperiodtype * @return An ::icalperiodtype representing a null period * @sa icalperiodtype_is_null_period() * - * ### Usage + * @par Usage * ```c * // creates null period * struct icalperiodtype period = icalperiodtype_null_period(); @@ -158,7 +149,7 @@ LIBICAL_ICAL_EXPORT struct icalperiodtype icalperiodtype_null_period(void); * @return 1 if @a p is a null period, 0 otherwise * @sa icalperiodtype_null_period() * - * ### Usage + * @par Usage * ```c * // creates null period * struct icalperiodtype period = icalperiodtype_null_period(); @@ -174,7 +165,7 @@ LIBICAL_ICAL_EXPORT int icalperiodtype_is_null_period(struct icalperiodtype p); * @param p The time period to check * @return 1 if @a p is a valid period, 0 otherwise * - * ### Usage + * @par Usage * ```c * // creates null period * struct icalperiodtype period = icalperiodtype_null_period(); diff --git a/src/libical/icalproperty.c b/src/libical/icalproperty.c index a93d87ad..8227c185 100644 --- a/src/libical/icalproperty.c +++ b/src/libical/icalproperty.c @@ -2,18 +2,9 @@ FILE: icalproperty.c CREATOR: eric 28 April 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalproperty.c ======================================================================*/ @@ -67,7 +58,7 @@ icalproperty *icalproperty_new_impl(icalproperty_kind kind) if (!icalproperty_kind_is_valid(kind)) return NULL; - if ((prop = (icalproperty *) malloc(sizeof(icalproperty))) == 0) { + if ((prop = (icalproperty *) icalmemory_new_buffer(sizeof(icalproperty))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -160,7 +151,7 @@ icalproperty *icalproperty_new_from_string(const char *str) if (comp == 0) { icalerror_set_errno(ICAL_PARSE_ERROR); - free(buf); + icalmemory_free_buffer(buf); return 0; } @@ -171,7 +162,7 @@ icalproperty *icalproperty_new_from_string(const char *str) icalcomponent_remove_property(comp, prop); icalcomponent_free(comp); - free(buf); + icalmemory_free_buffer(buf); if (errors > 0) { icalproperty_free(prop); @@ -203,7 +194,7 @@ void icalproperty_free(icalproperty *p) pvl_free(p->parameters); if (p->x_name != 0) { - free(p->x_name); + icalmemory_free_buffer(p->x_name); } p->kind = ICAL_NO_PROPERTY; @@ -213,7 +204,7 @@ void icalproperty_free(icalproperty *p) p->x_name = 0; p->id[0] = 'X'; - free(p); + icalmemory_free_buffer(p); } /* This returns where the start of the next line should be. chars_left does @@ -422,13 +413,13 @@ char *icalproperty_as_ical_string_r(icalproperty *prop) } if (kind == ICAL_VALUE_PARAMETER) { - free((char *)kind_string); + icalmemory_free_buffer((char *)kind_string); continue; } icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";"); icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); - free((char *)kind_string); + icalmemory_free_buffer((char *)kind_string); } /* Append value */ @@ -447,7 +438,7 @@ char *icalproperty_as_ical_string_r(icalproperty *prop) icalmemory_append_string(&buf, &buf_ptr, &buf_size, "ERROR: No Value"); #endif } - free(str); + icalmemory_free_buffer(str); } else { #if ICAL_ALLOW_EMPTY_PROPERTIES == 0 icalmemory_append_string(&buf, &buf_ptr, &buf_size, "ERROR: No Value"); @@ -600,13 +591,13 @@ char *icalproperty_get_parameter_as_string_r(icalproperty *prop, const char *nam if (t == 0) { icalerror_set_errno(ICAL_INTERNAL_ERROR); - free(str); + icalmemory_free_buffer(str); return 0; } /* Strip the property name and the equal sign */ pv = icalmemory_strdup(t + 1); - free(str); + icalmemory_free_buffer(str); /* Is the string quoted? */ pvql = strchr(pv, '"'); @@ -616,13 +607,13 @@ char *icalproperty_get_parameter_as_string_r(icalproperty *prop, const char *nam /* Strip everything up to the first quote */ str = icalmemory_strdup(pvql + 1); - free(pv); + icalmemory_free_buffer(pv); /* Search for the end quote */ pvqr = strrchr(str, '"'); if (pvqr == 0) { icalerror_set_errno(ICAL_INTERNAL_ERROR); - free(str); + icalmemory_free_buffer(str); return 0; } @@ -812,7 +803,7 @@ void icalproperty_set_value_from_string(icalproperty *prop, const char *str, con if (nval == 0) { /* icalvalue_new_from_string sets errno */ - assert(icalerrno != ICAL_NO_ERROR); + icalassert(icalerrno != ICAL_NO_ERROR); return; } @@ -852,7 +843,7 @@ void icalproperty_set_x_name(icalproperty *prop, const char *name) icalerror_check_arg_rv((prop != 0), "prop"); if (prop->x_name != 0) { - free(prop->x_name); + icalmemory_free_buffer(prop->x_name); } prop->x_name = icalmemory_strdup(name); diff --git a/src/libical/icalproperty.h b/src/libical/icalproperty.h index e21bebb5..fdc4f57f 100644 --- a/src/libical/icalproperty.h +++ b/src/libical/icalproperty.h @@ -2,18 +2,10 @@ FILE: icalproperty.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALPROPERTY_H @@ -96,7 +88,7 @@ LIBICAL_ICAL_EXPORT void icalproperty_remove_parameter_by_name(icalproperty *pro /** @brief Removes the specified parameter reference from the property. * * @param prop A valid icalproperty. - * @param parameter A reference to a specific icalparameter. + * @param param A reference to a specific icalparameter. * * This function removes the specified parameter reference from the * property. diff --git a/src/libical/icalproperty_cxx.cpp b/src/libical/icalproperty_cxx.cpp index 6b542f19..6a377fec 100644 --- a/src/libical/icalproperty_cxx.cpp +++ b/src/libical/icalproperty_cxx.cpp @@ -3,18 +3,10 @@ * @author fnguyen (12/10/01) * @brief Implementation of C++ Wrapper for icalproperty.c * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #include "icalproperty_cxx.h" diff --git a/src/libical/icalproperty_cxx.h b/src/libical/icalproperty_cxx.h index e243dd2e..c81acfde 100644 --- a/src/libical/icalproperty_cxx.h +++ b/src/libical/icalproperty_cxx.h @@ -3,18 +3,10 @@ * @author fnguyen (12/10/01) * @brief Definition of C++ Wrapper for icalproperty.c * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #ifndef ICALPROPERTY_CXX_H diff --git a/src/libical/icalproperty_p.h b/src/libical/icalproperty_p.h index f8114a9e..dd0c9614 100644 --- a/src/libical/icalproperty_p.h +++ b/src/libical/icalproperty_p.h @@ -1,18 +1,10 @@ /*====================================================================== FILE: icalproperty_p.h - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALPROPERTY_P_H diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c index dd129bf3..96d4190f 100644 --- a/src/libical/icalrecur.c +++ b/src/libical/icalrecur.c @@ -2,18 +2,10 @@ FILE: icalrecur.c CREATOR: eric 16 May 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ========================================================================*/ /** @@ -169,12 +161,12 @@ static ical_invalid_rrule_handling invalidRruleHandling = ICAL_RRULE_TREAT_AS_ER #define ICAL_BY_YEARDAY_SIZE 367 /* 1 to 366 */ #endif -#if (SIZEOF_TIME_T > 4) +#if (SIZEOF_ICALTIME_T > 4) /** Arbitrarily go up to 1000th anniversary of Gregorian calendar, since - 64-bit time_t values get us up to the tm_year limit of 2+ billion years. */ + 64-bit icaltime_t values get us up to the tm_year limit of 2+ billion years. */ #define MAX_TIME_T_YEAR 2582 #else -/** This is the last year we will go up to, since 32-bit time_t values +/** This is the last year we will go up to, since 32-bit icaltime_t values only go up to the start of 2038. */ #define MAX_TIME_T_YEAR 2037 #endif @@ -593,7 +585,7 @@ static int icalrecur_add_bydayrules(struct icalrecur_parser *parser, icalrecurrencetype_weekday wd; if (i == ICAL_BY_DAY_SIZE) { - free(vals_copy); + icalmemory_free_buffer(vals_copy); return -1; } @@ -624,7 +616,7 @@ static int icalrecur_add_bydayrules(struct icalrecur_parser *parser, /* Sanity check value */ if (wd == ICAL_NO_WEEKDAY || weekno >= ICAL_BY_WEEKNO_SIZE) { - free(vals_copy); + icalmemory_free_buffer(vals_copy); return -1; } @@ -632,7 +624,7 @@ static int icalrecur_add_bydayrules(struct icalrecur_parser *parser, array[i] = ICAL_RECURRENCE_ARRAY_MAX; } - free(vals_copy); + icalmemory_free_buffer(vals_copy); sort_bydayrules(parser); @@ -773,7 +765,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char *str) icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); } if (parser.rt.rscale) { - free(parser.rt.rscale); + icalmemory_free_buffer(parser.rt.rscale); } icalrecurrencetype_clear(&parser.rt); break; @@ -791,7 +783,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char *str) if (rruleHandlingSetting == ICAL_RRULE_TREAT_AS_ERROR) { icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); if (parser.rt.rscale) { - free(parser.rt.rscale); + icalmemory_free_buffer(parser.rt.rscale); } icalrecurrencetype_clear(&parser.rt); break; @@ -801,7 +793,7 @@ struct icalrecurrencetype icalrecurrencetype_from_string(const char *str) } } - free(parser.copy); + icalmemory_free_buffer(parser.copy); return parser.rt; } @@ -1451,9 +1443,18 @@ static int initialize_rscale(icalrecur_iterator *impl) UChar *tzid = (UChar *) UCAL_UNKNOWN_ZONE_ID; short is_hebrew = 0; - if (dtstart.zone) { - /* Convert the UTF8 timezoneid of dstart to ICU UChar. */ - const char *src = icaltimezone_get_tzid((icaltimezone *) dtstart.zone); + /* Convert the UTF8 timezoneid of dstart to ICU UChar. */ + const char *src = icaltimezone_get_location((icaltimezone *) dtstart.zone); + if (!src) { + const char *prefix = icaltimezone_tzid_prefix(); + + src = icaltimezone_get_tzid((icaltimezone *) dtstart.zone); + if (src && !strncmp(src, prefix, strlen(prefix))) { + /* Skip past our prefix */ + src += strlen(prefix); + } + } + if (src) { size_t len = (strlen(src) + 1) * U_SIZEOF_UCHAR; tzid = icalmemory_tmp_buffer(len); tzid = u_strFromUTF8Lenient(tzid, (int32_t)len, NULL, src, -1, &status); @@ -1956,7 +1957,7 @@ icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype rule, return 0; } - if (!(impl = (icalrecur_iterator *)malloc(sizeof(icalrecur_iterator)))) { + if (!(impl = (icalrecur_iterator *)icalmemory_new_buffer(sizeof(icalrecur_iterator)))) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -2017,7 +2018,7 @@ icalrecur_iterator *icalrecur_iterator_new(struct icalrecurrencetype rule, impl->orig_data[byrule] = 0; } else { icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); + icalmemory_free_buffer(impl); return 0; } } @@ -2061,7 +2062,7 @@ void icalrecur_iterator_free(icalrecur_iterator *i) } #endif - free(i); + icalmemory_free_buffer(i); } /** Calculate the number of days between 2 dates */ @@ -2171,7 +2172,7 @@ static int next_unit(icalrecur_iterator *impl, int end_of_data = 0; - assert(has_by_unit || this_frequency); + icalassert(has_by_unit || this_frequency); if (next_sub_unit && next_sub_unit(impl) == 0) { return 0; @@ -2243,7 +2244,7 @@ static int prev_unit(icalrecur_iterator *impl, int end_of_data = 0; - assert(has_by_unit || this_frequency); + icalassert(has_by_unit || this_frequency); if (prev_sub_unit && prev_sub_unit(impl) == 0) { return 0; @@ -3604,15 +3605,15 @@ short icalrecurrencetype_encode_month(int month, int is_leap) } int icalrecur_expand_recurrence(const char *rule, - time_t start, int count, time_t *array) + icaltime_t start, int count, icaltime_t *array) { struct icalrecurrencetype recur; icalrecur_iterator *ritr; - time_t tt; + icaltime_t tt; struct icaltimetype icstart, next; int i = 0; - memset(array, 0, count * sizeof(time_t)); + memset(array, 0, count * sizeof(icaltime_t)); icstart = icaltime_from_timet_with_zone(start, 0, 0); @@ -3632,7 +3633,7 @@ int icalrecur_expand_recurrence(const char *rule, icalrecur_iterator_free(ritr); } if(recur.rscale) - free(recur.rscale); + icalmemory_free_buffer(recur.rscale); return 1; } diff --git a/src/libical/icalrecur.h b/src/libical/icalrecur.h index f7fe5ce4..b541362f 100644 --- a/src/libical/icalrecur.h +++ b/src/libical/icalrecur.h @@ -2,18 +2,10 @@ FILE: icalrecur.h CREATOR: eric 20 March 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ========================================================================*/ /** @@ -359,15 +351,15 @@ LIBICAL_ICAL_EXPORT void icalrecur_iterator_free(icalrecur_iterator *); /** @brief Fills an array with the 'count' number of occurrences generated by * the rrule. * - * Specifically, this fills @p array up with at most 'count' time_t values, each + * Specifically, this fills @p array up with at most 'count' icaltime_t values, each * representing an occurrence time in seconds past the POSIX epoch. * * Note that the times are returned in UTC, but the times * are calculated in local time. You will have to convert the results * back into local time before using them. */ -LIBICAL_ICAL_EXPORT int icalrecur_expand_recurrence(const char *rule, time_t start, - int count, time_t *array); +LIBICAL_ICAL_EXPORT int icalrecur_expand_recurrence(const char *rule, icaltime_t start, + int count, icaltime_t *array); /* ical_invalid_rrule_handling : * How should the ICAL library handle RRULEs with invalid BYxxx part combos? diff --git a/src/libical/icalrestriction.c.in b/src/libical/icalrestriction.c.in index e36773f1..600ad5fd 100644 --- a/src/libical/icalrestriction.c.in +++ b/src/libical/icalrestriction.c.in @@ -1,18 +1,10 @@ /*====================================================================== File: icalrestriction.c - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /*#line 7 "icalrestriction.c.in"*/ @@ -28,34 +20,29 @@ /* Define the structs for the restrictions. these data are filled out in machine generated code below */ -struct icalrestriction_property_record; +struct icalrestriction_record; -typedef const char *(*restriction_func) (const struct icalrestriction_property_record * rec, +typedef const char *(*restriction_func) (const struct icalrestriction_record * rec, icalcomponent *comp, icalproperty *prop); -typedef struct icalrestriction_property_record +typedef struct icalrestriction_record { icalproperty_method method; icalcomponent_kind component; icalproperty_kind property; - icalrestriction_kind restriction; - restriction_func function; -} icalrestriction_property_record; - -typedef struct icalrestriction_component_record -{ - icalproperty_method method; - icalcomponent_kind component; icalcomponent_kind subcomponent; icalrestriction_kind restriction; restriction_func function; -} icalrestriction_component_record; +} icalrestriction_record; -static const icalrestriction_property_record *icalrestriction_get_property_restriction( - icalproperty_method method, icalcomponent_kind component, icalproperty_kind property); +static const icalrestriction_record *icalrestriction_get_restriction( + const icalrestriction_record *start, + icalproperty_method method, icalcomponent_kind component, + icalproperty_kind property, icalcomponent_kind subcomp); -static const icalrestriction_property_record null_prop_record = - { ICAL_METHOD_NONE, ICAL_NO_COMPONENT, ICAL_NO_PROPERTY, ICAL_RESTRICTION_UNKNOWN, NULL }; +static const icalrestriction_record null_restriction_record = + { ICAL_METHOD_NONE, ICAL_NO_COMPONENT, + ICAL_NO_PROPERTY, ICAL_NO_COMPONENT, ICAL_RESTRICTION_UNKNOWN, NULL }; /** Each row gives the result of comparing a restriction against a count. The columns in each row represent 0,1,2+. '-1' indicates @@ -104,265 +91,323 @@ int icalrestriction_compare(icalrestriction_kind restr, int count) /* Special case routines */ -static const char *icalrestriction_may_be_draft_final_canceled( - const icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop) +static const char *icalrestriction_validate_status_value( + const icalrestriction_record *rec, icalcomponent *comp, icalproperty *prop) { - icalproperty_status stat = icalproperty_get_status(prop); + icalproperty_status stat; - _unused(rec); _unused(comp); - if (!(stat == ICAL_STATUS_DRAFT || - stat == ICAL_STATUS_FINAL || - stat == ICAL_STATUS_CANCELLED)) { - return - "Failed iTIP restrictions for STATUS property. " - "Value must be one of DRAFT, FINAL, or CANCELED"; + if (!prop) { + return 0; } - return 0; -} - -static const char *icalrestriction_may_be_comp_need_process(const icalrestriction_property_record * - rec, icalcomponent *comp, - icalproperty *prop) -{ - icalproperty_status stat = icalproperty_get_status(prop); - - _unused(rec); - _unused(comp); - - if (!(stat == ICAL_STATUS_COMPLETED || - stat == ICAL_STATUS_NEEDSACTION || stat == ICAL_STATUS_INPROCESS)) { - return - "Failed iTIP restrictions for STATUS property. " - "Value must be one of COMPLETED, NEEDS-ACTION or IN-PROCESS"; + stat = icalproperty_get_status(prop); + + if (rec->method == ICAL_METHOD_CANCEL) { + switch (rec->component) { + case ICAL_VEVENT_COMPONENT: + case ICAL_VTODO_COMPONENT: + /* Hack. see rfc5546, 3.2.5 CANCEL for property STATUS. I don't + understand the note */ + break; + + case ICAL_VJOURNAL_COMPONENT: + case ICAL_VPOLL_COMPONENT: + if (stat != ICAL_STATUS_CANCELLED) { + return + "Failed iTIP restrictions for STATUS property. " + "Value must be CANCELLED"; + } + break; + + default: + break; + } + } else { + switch (rec->component) { + case ICAL_VEVENT_COMPONENT: + switch (rec->method) { + case ICAL_METHOD_PUBLISH: + case ICAL_METHOD_COUNTER: + if (!(stat == ICAL_STATUS_TENTATIVE || + stat == ICAL_STATUS_CONFIRMED || + stat == ICAL_STATUS_CANCELLED)) { + return + "Failed iTIP restrictions for STATUS property. " + "Value must be one of TENTATIVE, CONFIRMED or CANCELED"; + } + break; + + case ICAL_METHOD_REQUEST: + case ICAL_METHOD_ADD: + if (!(stat == ICAL_STATUS_TENTATIVE || + stat == ICAL_STATUS_CONFIRMED)) { + return + "Failed iTIP restrictions for STATUS property. " + "Value must be one of TENTATIVE or CONFIRMED"; + } + break; + + default: + break; + } + break; + + case ICAL_VTODO_COMPONENT: + switch (rec->method) { + case ICAL_METHOD_REQUEST: + case ICAL_METHOD_ADD: + case ICAL_METHOD_COUNTER: + if (!(stat == ICAL_STATUS_COMPLETED || + stat == ICAL_STATUS_NEEDSACTION || + stat == ICAL_STATUS_INPROCESS)) { + return + "Failed iTIP restrictions for STATUS property. " + "Value must be one of COMPLETED, NEEDS-ACTION or IN-PROCESS"; + } + break; + + default: + break; + } + break; + + default: + break; + } } return 0; } -static const char *icalrestriction_may_be_tent_conf(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) +static const char *icalrestriction_must_be_recurring(const icalrestriction_record * rec, + icalcomponent *comp, icalproperty *prop) { - icalproperty_status stat = icalproperty_get_status(prop); - _unused(rec); _unused(comp); - - if (!(stat == ICAL_STATUS_TENTATIVE || stat == ICAL_STATUS_CONFIRMED)) { - return - "Failed iTIP restrictions for STATUS property. " - "Value must be one of TENTATIVE or CONFIRMED"; - } - + _unused(prop); return 0; } -static const char *icalrestriction_may_be_tent_conf_cancel(const icalrestriction_property_record * - rec, icalcomponent *comp, - icalproperty *prop) +const char *icalrestriction_must_if_tz_ref(const icalrestriction_record * rec, + icalcomponent *comp, icalproperty *prop) { - icalproperty_status stat = icalproperty_get_status(prop); - _unused(rec); _unused(comp); - - if (!(stat == ICAL_STATUS_TENTATIVE || - stat == ICAL_STATUS_CONFIRMED || stat == ICAL_STATUS_CANCELLED)) { - return - "Failed iTIP restrictions for STATUS property. " - "Value must be one of TENTATIVE, CONFIRMED or CANCELED"; - } - + _unused(prop); return 0; } -static const char *icalrestriction_must_be_cancel_if_present( - const icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop) +static const char *icalrestriction_no_dtend(const icalrestriction_record * rec, + icalcomponent *comp, icalproperty *prop) { - /* This routine will not be called if prop == 0 */ - icalproperty_status stat = icalproperty_get_status(prop); - _unused(rec); - _unused(comp); - if (stat != ICAL_STATUS_CANCELLED) { - return "Failed iTIP restrictions for STATUS property. Value must be CANCELLED"; + if (prop != NULL && + icalcomponent_get_first_property(comp, ICAL_DTEND_PROPERTY)) { + return + "Failed iTIP restrictions for DTEND property. " + "The component must not have both DURATION and DTEND"; } return 0; } -static const char *icalrestriction_must_be_canceled_no_attendee( - const icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop) +static const char *icalrestriction_no_duration(const icalrestriction_record * rec, + icalcomponent *comp, icalproperty *prop) { _unused(rec); - _unused(comp); - _unused(prop); - /* Hack. see rfc5546, 3.2.5 CANCEL for property STATUS. I don't - understand the note */ - - return 0; -} - -static const char *icalrestriction_must_be_recurring(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) -{ - _unused(rec); - _unused(comp); - _unused(prop); - return 0; -} - -static const char *icalrestriction_must_have_duration(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) -{ - _unused(rec); - _unused(prop); - if (!icalcomponent_get_first_property(comp, ICAL_DURATION_PROPERTY)) { + if (prop != NULL && + icalcomponent_get_first_property(comp, ICAL_DURATION_PROPERTY)) { return "Failed iTIP restrictions for DURATION property. " - "This component must have a DURATION property"; + "The component must not have both DTEND and DURATION"; } return 0; } -static const char *icalrestriction_must_have_repeat(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) +static int _check_restriction(icalcomponent *comp, + const icalrestriction_record *record, + int count, icalproperty *prop) { - _unused(rec); - _unused(prop); - if (!icalcomponent_get_first_property(comp, ICAL_REPEAT_PROPERTY)) { - return - "Failed iTIP restrictions for REPEAT property. " - "This component must have a REPEAT property"; - } + icalrestriction_kind restr; + const char *funcr = 0; + int compare; - return 0; -} + restr = record->restriction; -const char *icalrestriction_must_if_tz_ref(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) -{ - _unused(rec); - _unused(comp); - _unused(prop); - return 0; -} + if (restr == ICAL_RESTRICTION_ONEEXCLUSIVE || + restr == ICAL_RESTRICTION_ONEMUTUAL) { -static const char *icalrestriction_no_dtend(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) -{ - _unused(rec); - _unused(prop); - if (icalcomponent_get_first_property(comp, ICAL_DTEND_PROPERTY)) { - return - "Failed iTIP restrictions for DTEND property. " - "The component must not have both DURATION and DTEND"; + /* First treat is as a 0/1 restriction */ + restr = ICAL_RESTRICTION_ZEROORONE; } - return 0; -} + compare = icalrestriction_compare(restr, count); -static const char *icalrestriction_no_duration(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) -{ - _unused(rec); - _unused(comp); - _unused(prop); + assert(compare != -1); - /* _no_dtend takes care of this one */ - return 0; -} + if (compare == 0) { +#define TMP_BUF_SIZE 1024 + char temp[TMP_BUF_SIZE]; + icalproperty *errProp; + icalparameter *errParam; + const char *type, *kind; + + if (record->subcomponent != ICAL_NO_COMPONENT) { + type = "component"; + kind = icalenum_component_kind_to_string(record->subcomponent); + } else { + type = "property"; + kind = icalenum_property_kind_to_string(record->property); + } -static const char *icalrestriction_must_be_email(const icalrestriction_property_record * rec, - icalcomponent *comp, icalproperty *prop) -{ - icalproperty_action stat = icalproperty_get_action(prop); + snprintf(temp, TMP_BUF_SIZE, + "Failed iTIP restrictions for %s %s. " + "Expected %s instances of the %s and got %d", + kind, type, restr_string_map[restr], type, count); + errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); + errProp = icalproperty_vanew_xlicerror(temp, errParam, 0); + icalcomponent_add_property(comp, errProp); + icalproperty_free(errProp); + } - _unused(rec); - _unused(comp); + if (record->function != NULL) { + funcr = record->function(record, comp, prop); + } + + if (funcr != 0) { + icalproperty *errProp; + icalparameter *errParam; - if (!(stat == ICAL_ACTION_EMAIL)) { - return "Failed iTIP restrictions for ACTION property. Value must be EMAIL."; + errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); + errProp = icalproperty_vanew_xlicerror(funcr, errParam, 0); + icalcomponent_add_property(comp, errProp); + icalproperty_free(errProp); + + compare = 0; } - return 0; + return compare; } -static int icalrestriction_check_component(icalproperty_method method, icalcomponent *comp) +static int icalrestriction_check_component(icalproperty_method method, + icalcomponent *comp) { - icalproperty_kind kind; - icalcomponent_kind comp_kind; - icalrestriction_kind restr; - const icalrestriction_property_record *prop_record; - const char *funcr = 0; - icalproperty *prop; - + icalcomponent_kind comp_kind, inner_kind; + icalproperty_kind prop_kind; + const icalrestriction_record *start_record; + icalproperty *method_prop = NULL; + icalcomponent *inner_comp; + const char *errStr = NULL; int count; int compare; int valid = 1; comp_kind = icalcomponent_isa(comp); + switch (comp_kind) { + case ICAL_VCALENDAR_COMPONENT: + if (!icalcomponent_get_first_real_component(comp)) { + + errStr = "Failed iTIP restrictions for VCALENDAR component. " + "Expected one or more \"real\" sub-components and got 0"; + } + + /* Get the Method property from the component */ + method_prop = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY); + break; + + case ICAL_VTIMEZONE_COMPONENT: + if (!icalcomponent_get_first_component(comp, ICAL_XSTANDARD_COMPONENT) && + !icalcomponent_get_first_component(comp, ICAL_XDAYLIGHT_COMPONENT)) { + + errStr = "Failed iTIP restrictions for VTIMEZONE component. " + "Expected one or more STANDARD/DAYLIGHT sub-components and got 0"; + } + + method = ICAL_METHOD_NONE; + break; + + default: + break; + } + + if (errStr != NULL) { + icalproperty *errProp; + icalparameter *errParam; + + errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); + errProp = icalproperty_vanew_xlicerror(errStr, errParam, 0); + icalcomponent_add_property(comp, errProp); + icalproperty_free(errProp); + + valid = 0; + } + /* Check all of the properties in this component */ - for (kind = ICAL_ANY_PROPERTY + 1; kind != ICAL_NO_PROPERTY; kind++) { - count = icalcomponent_count_properties(comp, kind); + start_record = icalrestriction_get_restriction(NULL, method, comp_kind, + ICAL_ANY_PROPERTY, + ICAL_NO_COMPONENT); - prop_record = icalrestriction_get_property_restriction(method, comp_kind, kind); + if (start_record != &null_restriction_record) { - restr = prop_record->restriction; + for (prop_kind = ICAL_ANY_PROPERTY + 1; + prop_kind != ICAL_NO_PROPERTY; prop_kind++) { - if (restr == ICAL_RESTRICTION_ONEEXCLUSIVE || restr == ICAL_RESTRICTION_ONEMUTUAL) { + const icalrestriction_record *record = + icalrestriction_get_restriction(start_record, method, comp_kind, + prop_kind, ICAL_NO_COMPONENT); - /* First treat is as a 0/1 restriction */ - restr = ICAL_RESTRICTION_ZEROORONE; - compare = icalrestriction_compare(restr, count); + icalproperty *prop = + icalcomponent_get_first_property(comp, prop_kind); - } else { + count = icalcomponent_count_properties(comp, prop_kind); + + compare = _check_restriction(comp, record, count, prop); - compare = icalrestriction_compare(restr, count); + valid = valid && compare; } + } - assert(compare != -1); + /* Now check the inner components */ - if (compare == 0) { -#define TMP_BUF_SIZE 1024 - char temp[TMP_BUF_SIZE]; - icalproperty *errProp; - icalparameter *errParam; - - snprintf(temp, TMP_BUF_SIZE, - "Failed iTIP restrictions for %s property. " - "Expected %s instances of the property and got %d", - icalenum_property_kind_to_string(kind), restr_string_map[restr], count); - errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); - errProp = icalproperty_vanew_xlicerror(temp, errParam, 0); - icalcomponent_add_property(comp, errProp); - icalproperty_free(errProp); - } + start_record = icalrestriction_get_restriction(start_record, method, comp_kind, + ICAL_NO_PROPERTY, + ICAL_ANY_COMPONENT); - prop = icalcomponent_get_first_property(comp, kind); + if (start_record != &null_restriction_record) { - if (prop != 0 && prop_record->function != NULL) { - funcr = prop_record->function(prop_record, comp, prop); - } + for (inner_kind = ICAL_NO_COMPONENT + 3; + inner_kind != ICAL_NUM_COMPONENT_TYPES; inner_kind++) { - if (funcr != 0) { - icalproperty *errProp; - icalparameter *errParam; + const icalrestriction_record *record = + icalrestriction_get_restriction(start_record, method, comp_kind, + ICAL_NO_PROPERTY, inner_kind); - errParam = icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP); - errProp = icalproperty_vanew_xlicerror(funcr, errParam, 0); - icalcomponent_add_property(comp, errProp); - icalproperty_free(errProp); + count = icalcomponent_count_components(comp, inner_kind); - compare = 0; + compare = _check_restriction(comp, record, count, NULL); + + valid = valid && compare; } + } + + if (method_prop == 0) { + method = ICAL_METHOD_NONE; + } else { + method = icalproperty_get_method(method_prop); + } + + for (inner_comp = icalcomponent_get_first_component(comp, ICAL_ANY_COMPONENT); + inner_comp != 0; + inner_comp = icalcomponent_get_next_component(comp, ICAL_ANY_COMPONENT)) { + + compare = icalrestriction_check_component(method, inner_comp); valid = valid && compare; } @@ -373,15 +418,10 @@ static int icalrestriction_check_component(icalproperty_method method, icalcompo int icalrestriction_check(icalcomponent *outer_comp) { icalcomponent_kind comp_kind; - icalproperty_method method; - icalcomponent *inner_comp; - icalproperty *method_prop; int valid; icalerror_check_arg_rz((outer_comp != 0), "outer comp"); - /* Get the Method value from the outer component */ - comp_kind = icalcomponent_isa(outer_comp); if (comp_kind != ICAL_VCALENDAR_COMPONENT) { @@ -389,43 +429,198 @@ int icalrestriction_check(icalcomponent *outer_comp) return 0; } - method_prop = icalcomponent_get_first_property(outer_comp, ICAL_METHOD_PROPERTY); - - if (method_prop == 0) { - method = ICAL_METHOD_NONE; - } else { - method = icalproperty_get_method(method_prop); - } - /* Check the VCALENDAR wrapper */ valid = icalrestriction_check_component(ICAL_METHOD_NONE, outer_comp); - /* Now check the inner components */ + return valid; +} - for (inner_comp = icalcomponent_get_first_component(outer_comp, ICAL_ANY_COMPONENT); - inner_comp != 0; - inner_comp = icalcomponent_get_next_component(outer_comp, ICAL_ANY_COMPONENT)) { - valid = valid && icalrestriction_check_component(method, inner_comp); +static const char *icalrestriction_validate_valarm_prop( + const icalrestriction_record *rec, icalcomponent *comp, icalproperty *prop) +{ + icalrestriction_record record = + { ICAL_METHOD_NONE, ICAL_VALARM_COMPONENT, + rec->property, ICAL_NO_COMPONENT, ICAL_RESTRICTION_UNKNOWN, NULL }; + const icalrestriction_record *myrec = NULL; + enum icalproperty_action action = ICAL_ACTION_NONE; + icalproperty *action_prop; + int count = 0; + + switch (rec->subcomponent) { + case ICAL_NO_COMPONENT: + action_prop = icalcomponent_get_first_property(comp, ICAL_ACTION_PROPERTY); + + if (action_prop) { + action = icalproperty_get_action(action_prop); + } + + if (prop) { + if (rec->restriction == ICAL_RESTRICTION_ZEROPLUS || + rec->restriction == ICAL_RESTRICTION_ONEPLUS) { + count = icalcomponent_count_properties(comp, rec->property); + } else { + count = 1; + } + } + + switch (rec->property) { + case ICAL_DURATION_PROPERTY: + if (count && + !icalcomponent_get_first_property(comp, ICAL_DURATION_PROPERTY)) { + return + "Failed iTIP restrictions for REPEAT property. " + "This component must have a REPEAT property " + "if it has a DURATION property"; + } + break; + + case ICAL_REPEAT_PROPERTY: + if (count && + !icalcomponent_get_first_property(comp, ICAL_DURATION_PROPERTY)) { + return + "Failed iTIP restrictions for DURATION property. " + "This component must have a DURATION property " + "if it has a REPEAT property"; + } + break; + + case ICAL_ATTACH_PROPERTY: + if (count) { + switch (action) { + case ICAL_ACTION_AUDIO: + case ICAL_ACTION_PROCEDURE: + record.restriction = ICAL_RESTRICTION_ZEROORONE; + myrec = &record; + break; + + case ICAL_ACTION_DISPLAY: + record.restriction = ICAL_RESTRICTION_ZERO; + myrec = &record; + break; + + default: + break; + } + break; + } + break; + + case ICAL_ATTENDEE_PROPERTY: + switch (action) { + case ICAL_ACTION_AUDIO: + case ICAL_ACTION_DISPLAY: + case ICAL_ACTION_PROCEDURE: + if (count) { + record.restriction = ICAL_RESTRICTION_ZERO; + myrec = &record; + } + break; + + case ICAL_ACTION_EMAIL: + if (!count) { + record.restriction = ICAL_RESTRICTION_ONEPLUS; + myrec = &record; + } + break; + + default: + break; + } + break; + + case ICAL_DESCRIPTION_PROPERTY: + switch (action) { + case ICAL_ACTION_AUDIO: + if (count) { + record.restriction = ICAL_RESTRICTION_ZERO; + myrec = &record; + } + break; + + case ICAL_ACTION_DISPLAY: + case ICAL_ACTION_EMAIL: + if (!count) { + record.restriction = ICAL_RESTRICTION_ONE; + myrec = &record; + } + break; + + default: + break; + } + break; + + case ICAL_SUMMARY_PROPERTY: + switch (action) { + case ICAL_ACTION_AUDIO: + case ICAL_ACTION_DISPLAY: + case ICAL_ACTION_PROCEDURE: + if (count) { + record.restriction = ICAL_RESTRICTION_ZERO; + myrec = &record; + } + break; + + case ICAL_ACTION_EMAIL: + if (!count) { + record.restriction = ICAL_RESTRICTION_ONE; + myrec = &record; + } + break; + + default: + break; + } + break; + + default: + break; + } + break; + + case ICAL_VLOCATION_COMPONENT: + if (!icalcomponent_get_first_property(comp, ICAL_PROXIMITY_PROPERTY)) { + return + "Failed iTIP restrictions for VLOCATION component. " + "This component must only appear in a VALARM component " + "if the VALARM has a PROXIMITY property."; + } + break; + + default: + break; } - return valid; + if (myrec) { + _check_restriction(comp, myrec, count, NULL); + } + + return 0; } <insert_code_here> -static const icalrestriction_property_record *icalrestriction_get_property_restriction( - icalproperty_method method, icalcomponent_kind component, icalproperty_kind property) +static const icalrestriction_record *icalrestriction_get_restriction( + const icalrestriction_record *start, + icalproperty_method method, icalcomponent_kind component, + icalproperty_kind property, icalcomponent_kind subcomp) { - int i; + const icalrestriction_record *rec; + + if (!start) { + start = &icalrestriction_records[0]; + } - for (i = 0; icalrestriction_property_records[i].restriction != ICAL_RESTRICTION_NONE; i++) { + for (rec = start; rec && rec->restriction != ICAL_RESTRICTION_NONE; rec++) { - if (method == icalrestriction_property_records[i].method && - component == icalrestriction_property_records[i].component && - property == icalrestriction_property_records[i].property) { - return &icalrestriction_property_records[i]; + if (method == rec->method && + (component == ICAL_ANY_COMPONENT || + (component == rec->component && + (property == ICAL_ANY_PROPERTY || property == rec->property) && + (subcomp == ICAL_ANY_COMPONENT || subcomp == rec->subcomponent)))) { + return rec; } } - return &null_prop_record; + return &null_restriction_record; } diff --git a/src/libical/icalrestriction.h b/src/libical/icalrestriction.h index 38751efc..47d9d07a 100644 --- a/src/libical/icalrestriction.h +++ b/src/libical/icalrestriction.h @@ -2,18 +2,9 @@ FILE: icalrestriction.h CREATOR: eric 24 April 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalrestriction.h @@ -26,7 +17,7 @@ /** * @file icalrestriction.h - * @brief Functions to check if an ::icalcomponent meets the restrictions + * @brief Functions to check if an icalcomponent meets the restrictions * imposed by the standard. */ @@ -76,7 +67,7 @@ typedef enum icalrestriction_kind * @param count The amount present that is to be checked against the restriction * @return 1 if the restriction is met, 0 if not * - * ### Example + * @par Example * ```c * assert(icalrestriction_compare(ICALRESTRICTION_ONEPLUS, 5) == true); * assert(icalrestriction_compare(ICALRESTRICTION_NONE, 3) == false); @@ -94,7 +85,7 @@ LIBICAL_ICAL_EXPORT int icalrestriction_compare(icalrestriction_kind restr, int * Returns 0 and sets ::icalerrno if `NULL` is passed as @a comp, or if the * component is not a `VCALENDAR`. * - * ### Example + * @par Example * ```c * icalcomponent *component = // ... * diff --git a/src/libical/icaltime.c b/src/libical/icaltime.c index fd1bf3d8..d98880b2 100644 --- a/src/libical/icaltime.c +++ b/src/libical/icaltime.c @@ -2,20 +2,11 @@ FILE: icaltime.c CREATOR: eric 02 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> The timegm code is Copyright (c) 2001-2006, NLnet Labs. All rights reserved. - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -77,16 +68,16 @@ static int icaltime_leap_days(int y1, int y2) /* * Code adapted from Python 2.4.1 sources (Lib/calendar.py). */ -static time_t icaltime_timegm(const struct tm *tm) +static icaltime_t icaltime_timegm(const struct tm *tm) { int year; - time_t days; - time_t hours; - time_t minutes; - time_t seconds; + icaltime_t days; + icaltime_t hours; + icaltime_t minutes; + icaltime_t seconds; year = 1900 + tm->tm_year; - days = (time_t)(365 * (year - 1970) + icaltime_leap_days(1970, year)); + days = (icaltime_t)(365 * (year - 1970) + icaltime_leap_days(1970, year)); days += days_in_year_passed_month[0][tm->tm_mon]; if (tm->tm_mon > 1 && icaltime_is_leap_year(year)) @@ -102,40 +93,40 @@ static time_t icaltime_timegm(const struct tm *tm) /* * Function to convert a struct tm time specification - * to an ANSI time_t using the specified time zone. + * to an ANSI-compatible icaltime_t using the specified time zone. * This is different from the standard mktime() function * in that we don't want the automatic adjustments for * local daylight savings time applied to the result. * This function expects well-formed input. */ -static time_t make_time(struct tm *tm, int tzm) +static icaltime_t make_time(struct tm *tm, int tzm) { - time_t tim; + icaltime_t tim; static int days[] = { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 }; /* check that month specification within range */ if (tm->tm_mon < 0 || tm->tm_mon > 11) - return ((time_t) - 1); + return ((icaltime_t) - 1); -#if (SIZEOF_TIME_T == 4) +#if (SIZEOF_ICALTIME_T == 4) /* check that year specification within range */ if (tm->tm_year < 70 || tm->tm_year > 138) - return ((time_t) - 1); + return ((icaltime_t) - 1); /* check for upper bound of Jan 17, 2038 (to avoid possibility of 32-bit arithmetic overflow) */ if (tm->tm_year == 138) { if (tm->tm_mon > 0) { - return ((time_t) - 1); + return ((icaltime_t) - 1); } else if (tm->tm_mday > 17) { - return ((time_t) - 1); + return ((icaltime_t) - 1); } } -#endif /* SIZEOF_TIME_T */ +#endif /* SIZEOF_ICALTIME_T */ /* * calculate elapsed days since start of the epoch (midnight Jan @@ -143,7 +134,7 @@ static time_t make_time(struct tm *tm, int tzm) * (number of leap days to subtract) */ - tim = (time_t) ((tm->tm_year - 70) * 365 + ((tm->tm_year - 1) / 4) - 17); + tim = (icaltime_t) ((tm->tm_year - 70) * 365 + ((tm->tm_year - 1) / 4) - 17); /* add number of days elapsed in the current year */ @@ -180,7 +171,7 @@ static time_t make_time(struct tm *tm, int tzm) return (tim); } -struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, const int is_date, +struct icaltimetype icaltime_from_timet_with_zone(const icaltime_t tm, const int is_date, const icaltimezone *zone) { struct icaltimetype tt; @@ -189,8 +180,8 @@ struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, const int is_ utc_zone = icaltimezone_get_utc_timezone(); - /* Convert the time_t to a struct tm in UTC time. We can trust gmtime for this. */ - if (!gmtime_r(&tm, &t)) + /* Convert the icaltime_t to a struct tm in UTC time. We can trust gmtime for this. */ + if (!icalgmtime_r(&tm, &t)) return is_date ? icaltime_null_date () : icaltime_null_time (); tt.year = t.tm_year + 1900; @@ -220,18 +211,18 @@ struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, const int is_ struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone) { - return icaltime_from_timet_with_zone(time(NULL), 0, zone); + return icaltime_from_timet_with_zone(icaltime(NULL), 0, zone); } struct icaltimetype icaltime_today(void) { - return icaltime_from_timet_with_zone(time(NULL), 1, NULL); + return icaltime_from_timet_with_zone(icaltime(NULL), 1, NULL); } -time_t icaltime_as_timet(const struct icaltimetype tt) +icaltime_t icaltime_as_timet(const struct icaltimetype tt) { struct tm stm; - time_t t; + icaltime_t t; /* If the time is the special null time, return 0. */ if (icaltime_is_null_time(tt)) { @@ -259,11 +250,11 @@ time_t icaltime_as_timet(const struct icaltimetype tt) return t; } -time_t icaltime_as_timet_with_zone(const struct icaltimetype tt, const icaltimezone *zone) +icaltime_t icaltime_as_timet_with_zone(const struct icaltimetype tt, const icaltimezone *zone) { icaltimezone *utc_zone; struct tm stm; - time_t t; + icaltime_t t; struct icaltimetype local_tt; utc_zone = icaltimezone_get_utc_timezone(); @@ -434,7 +425,7 @@ static const int _days_in_month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, int icaltime_days_in_month(const int month, const int year) { - int days = _days_in_month[month]; + int days; /* The old code aborting if it was passed a parameter like BYMONTH=0 * Unfortunately it's not practical right now to pass an error all @@ -448,6 +439,8 @@ int icaltime_days_in_month(const int month, const int year) return 30; } + days = _days_in_month[month]; + if (month == 2) { days += icaltime_is_leap_year(year); } diff --git a/src/libical/icaltime.h b/src/libical/icaltime.h.cmake index 1e28492b..90b62ce8 100644 --- a/src/libical/icaltime.h +++ b/src/libical/icaltime.h.cmake @@ -2,18 +2,9 @@ FILE: icaltime.h CREATOR: eric 02 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -37,7 +28,7 @@ * - icaltime_null_date() * - icaltime_current_time_with_zone() * - icaltime_today() - * - icaltime_from_timet_with_zone(time_t tm, int is_date, + * - icaltime_from_timet_with_zone(icaltime_t tm, int is_date, * icaltimezone *zone) * - icaltime_from_day_of_year(int doy, int year) * @@ -83,6 +74,7 @@ #include "libical_ical_export.h" #include <time.h> +#define icaltime_t ${ICAL_ICALTIME_T_TYPE} /* An opaque struct representing a timezone. We declare this here to avoid a circular dependency. */ @@ -94,8 +86,8 @@ typedef struct _icaltimezone icaltimezone; /** icaltime_span is returned by icalcomponent_get_span() */ struct icaltime_span { - time_t start; /**< in UTC */ - time_t end; /**< in UTC */ + icaltime_t start; /**< in UTC */ + icaltime_t end; /**< in UTC */ int is_busy; /**< 1->busy time, 0-> free time */ }; @@ -169,7 +161,7 @@ LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_today(void); * target timezone with no need to store the source timezone. * */ -LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, +LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_timet_with_zone(const icaltime_t tm, const int is_date, const icaltimezone *zone); @@ -199,7 +191,7 @@ LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_from_day_of_year(const int doy, * only pass an icaltime in UTC, since no conversion is done. Even in that case, * it's probably better to just use icaltime_as_timet_with_zone(). */ -LIBICAL_ICAL_EXPORT time_t icaltime_as_timet(const struct icaltimetype); +LIBICAL_ICAL_EXPORT icaltime_t icaltime_as_timet(const struct icaltimetype); /** @brief Returns the time as seconds past the UNIX epoch, using the * given timezone. @@ -207,9 +199,9 @@ LIBICAL_ICAL_EXPORT time_t icaltime_as_timet(const struct icaltimetype); * This convenience method combines a call to icaltime_convert_to_zone() * with a call to icaltime_as_timet(). * If the input timezone is null, no conversion is done; that is, the - * time is simply returned as time_t in its native timezone. + * time is simply returned as icaltime_t in its native timezone. */ -LIBICAL_ICAL_EXPORT time_t icaltime_as_timet_with_zone(const struct icaltimetype tt, +LIBICAL_ICAL_EXPORT icaltime_t icaltime_as_timet_with_zone(const struct icaltimetype tt, const icaltimezone *zone); /** @@ -352,7 +344,7 @@ LIBICAL_ICAL_EXPORT void icaltime_adjust(struct icaltimetype *tt, * to do arithmetic on times without worrying about overflow or * underflow. */ -LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_normalize(const struct icaltimetype t); +LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_normalize(const struct icaltimetype tt); /** @brief Converts time to a given timezone. * @@ -363,7 +355,7 @@ LIBICAL_ICAL_EXPORT struct icaltimetype icaltime_normalize(const struct icaltime * * If it's a floating time, the returned object * represents the same time relative to @p zone. - * For example, if @tt represents 9:30 AM floating and @p zone + * For example, if @p tt represents 9:30 AM floating and @p zone * is the GMT timezone, the returned object will represent 9:30 AM GMT. * * Otherwise, the time will be converted to @p zone, and its timezone diff --git a/src/libical/icaltimezone.c b/src/libical/icaltimezone.c index e57c08d2..b272c0f0 100644 --- a/src/libical/icaltimezone.c +++ b/src/libical/icaltimezone.c @@ -2,18 +2,10 @@ FILE: icaltimezone.c CREATOR: Damon Chaplin 15 March 2001 - (C) COPYRIGHT 2001, Damon Chaplin <damon@ximian.com> + SPDX-FileCopyrightText: 2001, Damon Chaplin <damon@ximian.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ //krazy:excludeall=cpp @@ -85,12 +77,12 @@ static char s_ical_tzid_prefix[BUILTIN_TZID_PREFIX_LEN] = {0}; the timezone changes. */ #define ICALTIMEZONE_EXTRA_COVERAGE 5 -#if (SIZEOF_TIME_T > 4) +#if (SIZEOF_ICALTIME_T > 4) /** Arbitrarily go up to 1000th anniversary of Gregorian calendar, since - 64-bit time_t values get us up to the tm_year limit of 2+ billion years. */ + 64-bit icaltime_t values get us up to the tm_year limit of 2+ billion years. */ #define ICALTIMEZONE_MAX_YEAR 2582 #else -/** This is the maximum year we will expand to, since 32-bit time_t values +/** This is the maximum year we will expand to, since 32-bit icaltime_t values only go up to the start of 2038. */ #define ICALTIMEZONE_MAX_YEAR 2037 #endif @@ -212,7 +204,7 @@ icaltimezone *icaltimezone_new(void) { icaltimezone *zone; - zone = (icaltimezone *) malloc(sizeof(icaltimezone)); + zone = (icaltimezone *) icalmemory_new_buffer(sizeof(icaltimezone)); if (!zone) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return NULL; @@ -227,7 +219,7 @@ icaltimezone *icaltimezone_copy(icaltimezone *originalzone) { icaltimezone *zone; - zone = (icaltimezone *) malloc(sizeof(icaltimezone)); + zone = (icaltimezone *) icalmemory_new_buffer(sizeof(icaltimezone)); if (!zone) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return NULL; @@ -235,13 +227,13 @@ icaltimezone *icaltimezone_copy(icaltimezone *originalzone) memcpy(zone, originalzone, sizeof(icaltimezone)); if (zone->tzid != NULL) { - zone->tzid = strdup(zone->tzid); + zone->tzid = icalmemory_strdup(zone->tzid); } if (zone->location != NULL) { - zone->location = strdup(zone->location); + zone->location = icalmemory_strdup(zone->location); } if (zone->tznames != NULL) { - zone->tznames = strdup(zone->tznames); + zone->tznames = icalmemory_strdup(zone->tznames); } icaltimezone_changes_lock(); @@ -261,7 +253,7 @@ void icaltimezone_free(icaltimezone *zone, int free_struct) { icaltimezone_reset(zone); if (free_struct) - free(zone); + icalmemory_free_buffer(zone); } /** @brief Resets the icaltimezone to the initial state, freeing most of the @@ -270,13 +262,13 @@ void icaltimezone_free(icaltimezone *zone, int free_struct) static void icaltimezone_reset(icaltimezone *zone) { if (zone->tzid) - free(zone->tzid); + icalmemory_free_buffer(zone->tzid); if (zone->location) - free(zone->location); + icalmemory_free_buffer(zone->location); if (zone->tznames) - free(zone->tznames); + icalmemory_free_buffer(zone->tznames); if (zone->component) icalcomponent_free(zone->component); @@ -329,9 +321,9 @@ static int icaltimezone_get_vtimezone_properties(icaltimezone *zone, icalcompone } if (zone->tzid) { - free(zone->tzid); + icalmemory_free_buffer(zone->tzid); } - zone->tzid = strdup(tzid); + zone->tzid = icalmemory_strdup(tzid); if (zone->component) { icalcomponent_free(zone->component); @@ -339,12 +331,12 @@ static int icaltimezone_get_vtimezone_properties(icaltimezone *zone, icalcompone zone->component = component; if (zone->location) { - free(zone->location); + icalmemory_free_buffer(zone->location); } zone->location = icaltimezone_get_location_from_vtimezone(component); if (zone->tznames) { - free(zone->tznames); + icalmemory_free_buffer(zone->tznames); } zone->tznames = icaltimezone_get_tznames_from_vtimezone(component); @@ -361,7 +353,7 @@ char *icaltimezone_get_location_from_vtimezone(icalcomponent *component) if (prop) { location = icalproperty_get_location(prop); if (location) - return strdup(location); + return icalmemory_strdup(location); } prop = icalcomponent_get_first_property(component, ICAL_X_PROPERTY); @@ -370,7 +362,7 @@ char *icaltimezone_get_location_from_vtimezone(icalcomponent *component) if (name && !strcasecmp(name, "X-LIC-LOCATION")) { location = icalproperty_get_x(prop); if (location) - return strdup(location); + return icalmemory_strdup(location); } prop = icalcomponent_get_next_property(component, ICAL_X_PROPERTY); } @@ -463,11 +455,11 @@ char *icaltimezone_get_tznames_from_vtimezone(icalcomponent *component) char *tznames; if (!strcmp(standard_tzname, daylight_tzname)) - return strdup(standard_tzname); + return icalmemory_strdup(standard_tzname); standard_len = strlen(standard_tzname); daylight_len = strlen(daylight_tzname); - tznames = malloc(standard_len + daylight_len + 2); + tznames = icalmemory_new_buffer(standard_len + daylight_len + 2); strcpy(tznames, standard_tzname); tznames[standard_len] = '/'; strcpy(tznames + standard_len + 1, daylight_tzname); @@ -477,7 +469,7 @@ char *icaltimezone_get_tznames_from_vtimezone(icalcomponent *component) /* If either of the TZNAMEs was found just return that, else NULL. */ tznames = standard_tzname ? standard_tzname : daylight_tzname; - return tznames ? strdup(tznames) : NULL; + return tznames ? icalmemory_strdup(tznames) : NULL; } } @@ -1431,9 +1423,9 @@ static int get_offset(icaltimezone *zone) struct tm local; struct icaltimetype tt; int offset; - const time_t now = time(NULL); + const icaltime_t now = icaltime(NULL); - if (!gmtime_r(&now, &local)) + if (!icalgmtime_r(&now, &local)) return 0; tt = tm_to_icaltimetype(&local); @@ -1575,7 +1567,7 @@ static int parse_coord(char *coord, int len, int *degrees, int *minutes, int *se } else if (len == 8) { sscanf(coord + 1, "%3d%2d%2d", degrees, minutes, seconds); } else { - fprintf(stderr, "Invalid coordinate: %s\n", coord); + icalerrprintf("Invalid coordinate: %s\n", coord); return 1; } @@ -1605,7 +1597,7 @@ static int fetch_lat_long_from_string(const char *str, sptr++; } len = (ptrdiff_t) (sptr - temp); - lat = (char *)malloc(len + 1); + lat = (char *)icalmemory_new_buffer(len + 1); memset(lat, '\0', len + 1); strncpy(lat, temp, len); lat[len] = '\0'; @@ -1647,11 +1639,11 @@ static int fetch_lat_long_from_string(const char *str, latitude_seconds) == 1 || parse_coord(lon, (int)strlen(lon), longitude_degrees, longitude_minutes, longitude_seconds) == 1) { - free(lat); + icalmemory_free_buffer(lat); return 1; } - free(lat); + icalmemory_free_buffer(lat); return 0; } @@ -1704,7 +1696,7 @@ static void icaltimezone_parse_zone_tab(void) filename_len += strlen(zonetab); filename_len += 2; /* for dir separator and final '\0' */ - filename = (char *)malloc(filename_len); + filename = (char *)icalmemory_new_buffer(filename_len); if (!filename) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return; @@ -1712,7 +1704,7 @@ static void icaltimezone_parse_zone_tab(void) snprintf(filename, filename_len, "%s/%s", zonedir, zonetab); fp = fopen(filename, "r"); - free(filename); + icalmemory_free_buffer(filename); icalerror_assert(fp, "Cannot open the zonetab file for reading"); if (!fp) { icalerror_set_errno(ICAL_INTERNAL_ERROR); @@ -1732,7 +1724,7 @@ static void icaltimezone_parse_zone_tab(void) if (sscanf(buf, "%1000s", location) != 1) { /*limit location to 1000chars */ /*increase as needed */ /*see location and buf declarations */ - fprintf(stderr, "Invalid timezone description line: %s\n", buf); + icalerrprintf("Invalid timezone description line: %s\n", buf); continue; } } else if (sscanf(buf, "%4d%2d%2d %4d%2d%2d %1000s", /*limit location to 1000chars */ @@ -1742,7 +1734,7 @@ static void icaltimezone_parse_zone_tab(void) &latitude_seconds, &longitude_degrees, &longitude_minutes, &longitude_seconds, location) != 7) { - fprintf(stderr, "Invalid timezone description line: %s\n", buf); + icalerrprintf("Invalid timezone description line: %s\n", buf); continue; } } else { @@ -1751,13 +1743,13 @@ static void icaltimezone_parse_zone_tab(void) &latitude_seconds, &longitude_degrees, &longitude_minutes, &longitude_seconds, location)) { - fprintf(stderr, "Invalid timezone description line: %s\n", buf); + icalerrprintf("Invalid timezone description line: %s\n", buf); continue; } } icaltimezone_init(&zone); - zone.location = strdup(location); + zone.location = icalmemory_strdup(location); if (latitude_degrees >= 0) { zone.latitude = @@ -1803,7 +1795,7 @@ void icaltimezone_release_zone_tab(void) builtin_timezones = NULL; for (i = 0; i < mybuiltin_timezones->num_elements; i++) { - free(((icaltimezone *) icalarray_element_at(mybuiltin_timezones, i))->location); + icalmemory_free_buffer(((icaltimezone *) icalarray_element_at(mybuiltin_timezones, i))->location); } icalarray_free(mybuiltin_timezones); } @@ -1839,7 +1831,7 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone) filename_len = strlen(get_zone_directory()) + strlen(zone->location) + 6; - filename = (char *)malloc(filename_len); + filename = (char *)icalmemory_new_buffer(filename_len); if (!filename) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto out; @@ -1848,7 +1840,7 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone) snprintf(filename, filename_len, "%s/%s.ics", get_zone_directory(), zone->location); fp = fopen(filename, "r"); - free(filename); + icalmemory_free_buffer(filename); if (!fp) { icalerror_set_errno(ICAL_FILE_ERROR); goto out; @@ -1856,7 +1848,7 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone) /* ##### B.# Sun, 11 Nov 2001 04:04:29 +1100 this is where the MALFORMEDDATA error is being set, after the call to 'icalparser_parse' - fprintf(stderr, "** WARNING ** %s: %d %s\n", + icalerrprintf("** WARNING ** %s: %d %s\n", __FILE__, __LINE__, icalerror_strerror(icalerrno)); */ @@ -1880,11 +1872,11 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone) const char *tzid_prefix = icaltimezone_tzid_prefix(); new_tzid_len = strlen(tzid_prefix) + strlen(zone->location) + 1; - new_tzid = (char *)malloc(sizeof(char) * (new_tzid_len + 1)); + new_tzid = (char *)icalmemory_new_buffer(sizeof(char) * (new_tzid_len + 1)); if(new_tzid) { snprintf(new_tzid, new_tzid_len, "%s%s", tzid_prefix, zone->location); icalproperty_set_tzid(prop, new_tzid); - free(new_tzid); + icalmemory_free_buffer(new_tzid); } else { icalerror_set_errno(ICAL_NEWFAILED_ERROR); } @@ -2003,7 +1995,7 @@ static void format_utc_offset(int utc_offset, char *buffer, size_t buffer_size) hours, and daylight saving shouldn't change it by more than a few hours. (The maximum offset is 15 hours 56 minutes at present.) */ if (hours < 0 || hours >= 24 || minutes < 0 || minutes >= 60 || seconds < 0 || seconds >= 60) { - fprintf(stderr, "Warning: Strange timezone offset: H:%i M:%i S:%i\n", + icalerrprintf("Warning: Strange timezone offset: H:%i M:%i S:%i\n", hours, minutes, seconds); } @@ -2139,7 +2131,7 @@ static const char *get_zone_directory(void) zislashp1 = zislash + 1; strcat(dirname, (char *)zislashp1); if (stat(dirname, &st) == 0 && S_ISDIR(st.st_mode)) { - cache = strdup(dirname); + cache = icalmemory_strdup(dirname); return cache; } } @@ -2154,7 +2146,7 @@ void set_zone_directory(const char *path) if (zone_files_directory) free_zone_directory(); - zone_files_directory = malloc(strlen(path) + 1); + zone_files_directory = icalmemory_new_buffer(strlen(path) + 1); if (zone_files_directory != NULL) strcpy(zone_files_directory, path); @@ -2163,7 +2155,7 @@ void set_zone_directory(const char *path) void free_zone_directory(void) { if (zone_files_directory != NULL) { - free(zone_files_directory); + icalmemory_free_buffer(zone_files_directory); zone_files_directory = NULL; } } diff --git a/src/libical/icaltimezone.h b/src/libical/icaltimezone.h index 90951ac4..01677150 100644 --- a/src/libical/icaltimezone.h +++ b/src/libical/icaltimezone.h @@ -2,18 +2,10 @@ FILE: icaltimezone.h CREATOR: Damon Chaplin 15 March 2001 - (C) COPYRIGHT 2001, Damon Chaplin <damon@ximian.com> + SPDX-FileCopyrightText: 2001, Damon Chaplin <damon@ximian.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /** * @file icaltimezone.h diff --git a/src/libical/icaltimezoneimpl.h b/src/libical/icaltimezoneimpl.h index 5f869521..63725f03 100644 --- a/src/libical/icaltimezoneimpl.h +++ b/src/libical/icaltimezoneimpl.h @@ -2,18 +2,10 @@ FILE: icaltimezoneimpl.h CREATOR: glenn 07 March 2010 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALTIMEZONEIMPL_H diff --git a/src/libical/icaltypes.c b/src/libical/icaltypes.c index 97007134..99cbb42e 100644 --- a/src/libical/icaltypes.c +++ b/src/libical/icaltypes.c @@ -2,18 +2,10 @@ FILE: icaltypes.c CREATOR: eric 16 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H #include <config.h> diff --git a/src/libical/icaltypes.h b/src/libical/icaltypes.h index edbf003d..bad766b5 100644 --- a/src/libical/icaltypes.h +++ b/src/libical/icaltypes.h @@ -2,18 +2,10 @@ FILE: icaltypes.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALTYPES_H @@ -30,10 +22,11 @@ struct icaldatetimeperiodtype struct icalperiodtype period; }; +#define ICAL_GEO_LEN 16 struct icalgeotype { - double lat; - double lon; + char lat[ICAL_GEO_LEN]; + char lon[ICAL_GEO_LEN]; }; struct icaltriggertype diff --git a/src/libical/icaltz-util.c b/src/libical/icaltz-util.c index 88bd4ab6..a4a4db05 100644 --- a/src/libical/icaltz-util.c +++ b/src/libical/icaltz-util.c @@ -2,18 +2,9 @@ * Authors : * Chenthill Palanisamy <pchenthill@novell.com> * - * Copyright 2007, Novell, Inc. + * SPDX-FileCopyrightText: 2007, Novell, Inc. * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ //krazy:excludeall=cpp @@ -24,6 +15,7 @@ #include "icaltz-util.h" #include "icalerror.h" #include "icaltimezone.h" +#include "icalmemory.h" #include <stdlib.h> #include <limits.h> @@ -126,7 +118,7 @@ typedef struct typedef struct { - time_t transition; + icaltime_t transition; long int change; } leap; //@endcond @@ -190,7 +182,7 @@ static char *zname_from_stridx(char *str, size_t idx) size = i - idx; str += idx; - ret = (char *)malloc(size + 1); + ret = (char *)icalmemory_new_buffer(size + 1); ret = strncpy(ret, str, size); ret[size] = '\0'; @@ -270,7 +262,7 @@ static char *parse_posix_zone(char *p, ttinfo *type) size = strcspn(p, "-+0123456789,\n"); } - type->zname = (char *) malloc(size + 1); + type->zname = (char *) icalmemory_new_buffer(size + 1); strncpy(type->zname, p, size); type->zname[size] = '\0'; p += size; @@ -444,7 +436,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) const char *zonedir; FILE *f = NULL; char *full_path = NULL; - time_t *transitions = NULL; + icaltime_t *transitions = NULL; char *r_trans = NULL, *temp; int *trans_idx = NULL; ttinfo *types = NULL; @@ -484,7 +476,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) } size = strlen(zonedir) + strlen(location) + 2; - full_path = (char *)malloc(size); + full_path = (char *)icalmemory_new_buffer(size); if (full_path == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; @@ -506,7 +498,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) break; case '2': case '3': - if (sizeof(time_t) == 8) { + if (sizeof(icaltime_t) == 8) { trans_size = 8; } break; @@ -548,24 +540,24 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) } /* read data block */ - transitions = calloc(num_trans+1, sizeof(time_t)); // +1 for TZ string + transitions = icalmemory_new_buffer((num_trans+1) * sizeof(icaltime_t)); // +1 for TZ string if (transitions == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; } - r_trans = calloc(num_trans, (size_t)trans_size); + r_trans = icalmemory_new_buffer(num_trans * (size_t)trans_size); if (r_trans == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; } - trans_idx = calloc(num_trans+1, sizeof(int)); // +1 for TZ string + trans_idx = icalmemory_new_buffer((num_trans+1) * sizeof(int)); // +1 for TZ string if (trans_idx == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; } if (num_trans == 0) { // Add one transition using time type 0 at 19011213T204552Z - transitions[0] = (time_t)INT_MIN; + transitions[0] = (icaltime_t)INT_MIN; trans_idx[0] = 0; num_trans = 1; } else { @@ -574,16 +566,16 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) for (i = 0; i < num_trans; i++) { trans_idx[i] = fgetc(f); if (trans_size == 8) { - transitions[i] = (time_t) decode64(r_trans); + transitions[i] = (icaltime_t) decode64(r_trans); } else { - transitions[i] = (time_t) decode(r_trans); + transitions[i] = (icaltime_t) decode(r_trans); } r_trans += trans_size; } r_trans = temp; } - types = calloc(num_types+2, sizeof(ttinfo)); // +2 for TZ string + types = icalmemory_new_buffer((num_types+2) * sizeof(ttinfo)); // +2 for TZ string if (types == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; @@ -602,7 +594,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) types[i].gmtoff = decode(a); } - znames = (char *)malloc(num_chars); + znames = (char *)icalmemory_new_buffer(num_chars); if (znames == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; @@ -611,7 +603,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) /* We got all the information which we need */ - leaps = calloc(num_leaps, sizeof(leap)); + leaps = icalmemory_new_buffer(num_leaps * sizeof(leap)); if (leaps == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; @@ -621,9 +613,9 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) EFREAD(c, (size_t)trans_size, 1, f); if (trans_size == 8) { - leaps[i].transition = (time_t)decode64(c); + leaps[i].transition = (icaltime_t)decode64(c); } else { - leaps[i].transition = (time_t)decode(c); + leaps[i].transition = (icaltime_t)decode(c); } EFREAD(c, 4, 1, f); @@ -656,7 +648,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) /* Read the footer */ if (trans_size == 8 && - (footer[0] = fgetc(f)) == '\n' && + (footer[0] = (char)fgetc(f)) == '\n' && fgets(footer+1, (int) sizeof(footer)-1, f) && footer[strlen(footer)-1] == '\n') { tzstr = footer+1; @@ -739,7 +731,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) /* Add tzid property */ size = strlen(icaltimezone_tzid_prefix()) + strlen(location) + 1; - tzid = (char *)malloc(size); + tzid = (char *)icalmemory_new_buffer(size); if (tzid == NULL) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); goto error; @@ -756,7 +748,7 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) for (i = 0; i < num_trans; i++) { int by_day = 0; - time_t start; + icaltime_t start; enum icalrecurrencetype_weekday dow; prev_idx = idx; @@ -915,34 +907,34 @@ icalcomponent *icaltzutil_fetch_timezone(const char *location) fclose(f); if (full_path) - free(full_path); + icalmemory_free_buffer(full_path); if (transitions) - free(transitions); + icalmemory_free_buffer(transitions); if (r_trans) - free(r_trans); + icalmemory_free_buffer(r_trans); if (trans_idx) - free(trans_idx); + icalmemory_free_buffer(trans_idx); if (types) { for (i = 0; i < num_types; i++) { if (types[i].zname) { - free(types[i].zname); + icalmemory_free_buffer(types[i].zname); } } - free(types); + icalmemory_free_buffer(types); } if (znames) - free(znames); + icalmemory_free_buffer(znames); if (leaps) - free(leaps); + icalmemory_free_buffer(leaps); if (tzid) - free(tzid); + icalmemory_free_buffer(tzid); return tz_comp; } diff --git a/src/libical/icaltz-util.h b/src/libical/icaltz-util.h index 1f853a09..25879748 100644 --- a/src/libical/icaltz-util.h +++ b/src/libical/icaltz-util.h @@ -2,18 +2,9 @@ * Authors : * Chenthill Palanisamy <pchenthill@novell.com> * - * Copyright 2007, Novell, Inc. + * SPDX-FileCopyrightText: 2007, Novell, Inc. * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifndef ICALTZUTIL_H @@ -53,7 +44,9 @@ LIBICAL_ICAL_EXPORT void icaltzutil_set_zone_directory(const char *zonepath); * * @param location is a string containing the name of a location with a timezone file * found under the zoneinfo data. + * + * @since 3.1 no longer publicly accessible */ -LIBICAL_ICAL_EXPORT icalcomponent *icaltzutil_fetch_timezone(const char *location); +LIBICAL_ICAL_NO_EXPORT icalcomponent *icaltzutil_fetch_timezone(const char *location); #endif diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c index 81c48315..c41a69a3 100644 --- a/src/libical/icalvalue.c +++ b/src/libical/icalvalue.c @@ -2,18 +2,9 @@ FILE: icalvalue.c CREATOR: eric 02 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 Contributions from: Graham Davison <g.m.davison@computer.org> @@ -42,7 +33,7 @@ LIBICAL_ICAL_EXPORT struct icalvalue_impl *icalvalue_new_impl(icalvalue_kind kin if (!icalvalue_kind_is_valid(kind)) return NULL; - if ((v = (struct icalvalue_impl *)malloc(sizeof(struct icalvalue_impl))) == 0) { + if ((v = (struct icalvalue_impl *)icalmemory_new_buffer(sizeof(struct icalvalue_impl))) == 0) { icalerror_set_errno(ICAL_NEWFAILED_ERROR); return 0; } @@ -174,7 +165,7 @@ icalvalue *icalvalue_new_clone(const icalvalue *old) static char *icalmemory_strdup_and_dequote(const char *str) { const char *p; - char *out = (char *)malloc(sizeof(char) * strlen(str) + 1); + char *out = (char *)icalmemory_new_buffer(sizeof(char) * strlen(str) + 1); char *pout; int wroteNull = 0; @@ -311,7 +302,8 @@ static char *icalmemory_strdup_and_quote(const icalvalue *value, const char *unq https://tools.ietf.org/html/rfc5545#section-3.8.1.2 */ if ((icalproperty_isa(value->parent) == ICAL_CATEGORIES_PROPERTY) || (icalproperty_isa(value->parent) == ICAL_RESOURCES_PROPERTY) || - (icalproperty_isa(value->parent) == ICAL_POLLPROPERTIES_PROPERTY)) { + (icalproperty_isa(value->parent) == ICAL_POLLPROPERTIES_PROPERTY) || + (icalproperty_isa(value->parent) == ICAL_LOCATIONTYPE_PROPERTY)) { icalmemory_append_char(&str, &str_p, &buf_sz, *p); break; } @@ -365,23 +357,20 @@ static icalvalue *icalvalue_new_enum(icalvalue_kind kind, int x_type, const char } /** - * Transforms a simple float number string into a double. + * Extracts a simple floating point number as a substring. * The decimal separator (if any) of the double has to be '.' * The code is locale *independent* and does *not* change the locale. * It should be thread safe. - * If you want a code that does the same job with a decimal separator - * dependent on the current locale, then use strtof() from libc. */ -static int simple_str_to_double(const char *from, double *result, char **to) +static int simple_str_to_doublestr(const char *from, char *result, char **to) { -#define TMP_NUM_SIZE 100 char *start = NULL, *end = NULL, *cur = (char *)from; - char tmp_buf[TMP_NUM_SIZE + 1]; /*hack */ #if !defined(HAVE_GETNUMBERFORMAT) struct lconv *loc_data = localeconv(); #endif int i = 0; + double dtest; /*sanity checks */ if (!from || !result) { @@ -393,8 +382,7 @@ static int simple_str_to_double(const char *from, double *result, char **to) cur++; start = cur; - /* copy the part that looks like a double into tmp_buf - * so that we can call strtof() on it. + /* copy the part that looks like a double into result. * during the copy, we give ourselves a chance to convert the '.' * into the decimal separator of the current locale. */ @@ -406,7 +394,6 @@ static int simple_str_to_double(const char *from, double *result, char **to) /*huh hoh, number is too big. getting out */ return 1; } - memset(tmp_buf, 0, TMP_NUM_SIZE + 1); /* copy the float number string into tmp_buf, and take * care to have the (optional) decimal separator be the one @@ -417,18 +404,22 @@ static int simple_str_to_double(const char *from, double *result, char **to) if (start[i] == '.' && loc_data && loc_data->decimal_point && loc_data->decimal_point[0] && loc_data->decimal_point[0] != '.') { /*replace '.' by the digit separator of the current locale */ - tmp_buf[i] = loc_data->decimal_point[0]; + result[i] = loc_data->decimal_point[0]; } else { - tmp_buf[i] = start[i]; + result[i] = start[i]; } } #else - GetNumberFormat(LOCALE_SYSTEM_DEFAULT, 0, start, NULL, tmp_buf, TMP_NUM_SIZE); + GetNumberFormat(LOCALE_SYSTEM_DEFAULT, 0, start, NULL, result, TMP_NUM_SIZE); #endif if (to) { *to = end; } - *result = atof(tmp_buf); + + /* now try to convert to a floating point number, to check for validity only */ + if (sscanf(result, "%lf", &dtest) != 1) { + return 1; + } return 0; } @@ -569,7 +560,7 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind, char *dequoted_str = icalmemory_strdup_and_dequote(str); value = icalvalue_new_text(dequoted_str); - free(dequoted_str); + icalmemory_free_buffer(dequoted_str); break; } @@ -588,13 +579,14 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind, case ICAL_GEO_VALUE: { char *cur = NULL; - struct icalgeotype geo = { 0.0, 0.0 }; + struct icalgeotype geo; + memset(geo.lat, 0, ICAL_GEO_LEN); + memset(geo.lon, 0, ICAL_GEO_LEN); - if (simple_str_to_double(str, &geo.lat, &cur)) { + if (simple_str_to_doublestr(str, geo.lat, &cur)) { goto geo_parsing_error; } - - /*skip white spaces */ + /* skip white spaces */ while (cur && isspace((int)*cur)) { ++cur; } @@ -606,12 +598,12 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind, ++cur; - /*skip white spaces */ + /* skip white spaces */ while (cur && isspace((int)*cur)) { ++cur; } - if (simple_str_to_double(cur, &geo.lon, &cur)) { + if (simple_str_to_doublestr(cur, geo.lon, &cur)) { goto geo_parsing_error; } value = icalvalue_new_geo(geo); @@ -640,7 +632,7 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind, if (rt.freq != ICAL_NO_RECURRENCE) { value = icalvalue_new_recur(rt); } - free(rt.rscale); + icalmemory_free_buffer(rt.rscale); break; } @@ -727,7 +719,7 @@ static icalvalue *icalvalue_new_from_string_with_error(icalvalue_kind kind, char *dequoted_str = icalmemory_strdup_and_dequote(str); value = icalvalue_new_x(dequoted_str); - free(dequoted_str); + icalmemory_free_buffer(dequoted_str); } break; @@ -781,7 +773,7 @@ void icalvalue_free(icalvalue *v) } if (v->x_value != 0) { - free(v->x_value); + icalmemory_free_buffer(v->x_value); } switch (v->kind) { @@ -801,7 +793,7 @@ void icalvalue_free(icalvalue *v) case ICAL_QUERY_VALUE: { if (v->data.v_string != 0) { - free((void *)v->data.v_string); + icalmemory_free_buffer((void *)v->data.v_string); v->data.v_string = 0; } break; @@ -809,8 +801,8 @@ void icalvalue_free(icalvalue *v) case ICAL_RECUR_VALUE: { if (v->data.v_recur != 0) { - free(v->data.v_recur->rscale); - free((void *)v->data.v_recur); + icalmemory_free_buffer(v->data.v_recur->rscale); + icalmemory_free_buffer((void *)v->data.v_recur); v->data.v_recur = 0; } break; @@ -827,7 +819,7 @@ void icalvalue_free(icalvalue *v) v->parent = 0; memset(&(v->data), 0, sizeof(v->data)); v->id[0] = 'X'; - free(v); + icalmemory_free_buffer(v); } int icalvalue_is_valid(const icalvalue *value) @@ -904,10 +896,13 @@ static char *icalvalue_utcoffset_as_ical_string_r(const icalvalue *value) m = (data - (h * 3600)) / 60; s = (data - (h * 3600) - (m * 60)); + h = MIN(abs(h), 23); + m = MIN(abs(m), 59); + s = MIN(abs(s), 59); if (s != 0) { - snprintf(str, 9, "%c%02d%02d%02d", sign, abs(h), abs(m), abs(s)); + snprintf(str, 9, "%c%02d%02d%02d", sign, h, m, s); } else { - snprintf(str, 9, "%c%02d%02d", sign, abs(h), abs(m)); + snprintf(str, 9, "%c%02d%02d", sign, h, m); } return str; @@ -1075,7 +1070,7 @@ static char *icalvalue_float_as_ical_string_r(const icalvalue *value) /* bypass current locale in order to make sure snprintf uses a '.' as a separator set locate to 'C' and keep old locale */ - old_locale = strdup(setlocale(LC_NUMERIC, NULL)); + old_locale = icalmemory_strdup(setlocale(LC_NUMERIC, NULL)); (void)setlocale(LC_NUMERIC, "C"); str = (char *)icalmemory_new_buffer(40); @@ -1084,7 +1079,7 @@ static char *icalvalue_float_as_ical_string_r(const icalvalue *value) /* restore saved locale */ (void)setlocale(LC_NUMERIC, old_locale); - free(old_locale); + icalmemory_free_buffer(old_locale); return str; } @@ -1102,16 +1097,16 @@ static char *icalvalue_geo_as_ical_string_r(const icalvalue *value) /* bypass current locale in order to make * sure snprintf uses a '.' as a separator * set locate to 'C' and keep old locale */ - old_locale = strdup(setlocale(LC_NUMERIC, NULL)); + old_locale = icalmemory_strdup(setlocale(LC_NUMERIC, NULL)); (void)setlocale(LC_NUMERIC, "C"); str = (char *)icalmemory_new_buffer(80); - snprintf(str, 80, "%f;%f", data.lat, data.lon); + snprintf(str, 80, "%s;%s", data.lat, data.lon); /* restore saved locale */ (void)setlocale(LC_NUMERIC, old_locale); - free(old_locale); + icalmemory_free_buffer(old_locale); return str; } @@ -1393,8 +1388,8 @@ icalparameter_xliccomparetype icalvalue_compare(const icalvalue *a, const icalva temp1 = icalvalue_as_ical_string_r(a); temp2 = icalvalue_as_ical_string_r(b); r = strcmp(temp1, temp2); - free(temp1); - free(temp2); + icalmemory_free_buffer(temp1); + icalmemory_free_buffer(temp2); if (r > 0) { return ICAL_XLICCOMPARETYPE_GREATER; @@ -1500,12 +1495,12 @@ int icalvalue_encode_ical_string(const char *szText, char *szEncText, int nMaxBu if ((int)strlen(ptr) >= nMaxBufferLen) { icalvalue_free(value); - free(ptr); + icalmemory_free_buffer(ptr); return 0; } strcpy(szEncText, ptr); - free(ptr); + icalmemory_free_buffer(ptr); icalvalue_free((icalvalue *) value); diff --git a/src/libical/icalvalue.h b/src/libical/icalvalue.h index 382eee73..d6946dcc 100644 --- a/src/libical/icalvalue.h +++ b/src/libical/icalvalue.h @@ -2,18 +2,10 @@ FILE: icalvalue.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALVALUE_H diff --git a/src/libical/icalvalue_cxx.cpp b/src/libical/icalvalue_cxx.cpp index e8359667..f737bd4b 100644 --- a/src/libical/icalvalue_cxx.cpp +++ b/src/libical/icalvalue_cxx.cpp @@ -1,18 +1,10 @@ /*====================================================================== FILE: icalvalue_cxx.cpp CREATOR: fnguyen 12/21/01 - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H diff --git a/src/libical/icalvalue_cxx.h b/src/libical/icalvalue_cxx.h index 95124d59..b922debf 100644 --- a/src/libical/icalvalue_cxx.h +++ b/src/libical/icalvalue_cxx.h @@ -1,18 +1,10 @@ /*====================================================================== FILE: icalvalue_cxx.h CREATOR: fnguyen 12/13/01 - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALVALUE_CXX_H diff --git a/src/libical/icalvalueimpl.h b/src/libical/icalvalueimpl.h index 570409bd..0cd2f65f 100644 --- a/src/libical/icalvalueimpl.h +++ b/src/libical/icalvalueimpl.h @@ -2,18 +2,9 @@ FILE: icalvalue.c CREATOR: eric 02 May 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 Contributions from: Graham Davison (g.m.davison@computer.org) diff --git a/src/libical/icalversion.h.cmake b/src/libical/icalversion.h.cmake index 83fa2f54..06ea6ab3 100644 --- a/src/libical/icalversion.h.cmake +++ b/src/libical/icalversion.h.cmake @@ -2,18 +2,10 @@ FILE: icalversion.h CREATOR: eric 20 March 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICAL_VERSION_H diff --git a/src/libical/icptrholder_cxx.h b/src/libical/icptrholder_cxx.h index bd63fe5a..95b65e5c 100644 --- a/src/libical/icptrholder_cxx.h +++ b/src/libical/icptrholder_cxx.h @@ -25,18 +25,10 @@ * VComponentTmpPtr p;// VComponentTmpPtr is an instantiation of this template * for (p=component.get_first_component; p!= 0; p=component.get_next_component) { * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #ifndef ICPTRHOLDER_CXX_H @@ -106,13 +98,13 @@ public: T *operator->() const { - assert(ptr); + icalassert(ptr); return ptr; } T &operator*() { - assert(ptr); + icalassert(ptr); return *ptr; } diff --git a/src/libical/libical_deprecated.h b/src/libical/libical_deprecated.h index d1fa9dad..06fc28f1 100644 --- a/src/libical/libical_deprecated.h +++ b/src/libical/libical_deprecated.h @@ -1,3 +1,8 @@ +/** + SPDX-FileCopyrightText: Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +*/ + #ifndef LIBICAL_DEPRECATED_H #define LIBICAL_DEPRECATED_H diff --git a/src/libical/libical_ical_export.h b/src/libical/libical_ical_export.h index 2a2cb030..a4d7f66f 100644 --- a/src/libical/libical_ical_export.h +++ b/src/libical/libical_ical_export.h @@ -1,3 +1,8 @@ +/** + SPDX-FileCopyrightText: Allen Winter <winter@kde.org> + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +*/ + #ifndef LIBICAL_ICAL_EXPORT_H #define LIBICAL_ICAL_EXPORT_H diff --git a/src/libical/pvl.c b/src/libical/pvl.c index 960941a7..0695a342 100644 --- a/src/libical/pvl.c +++ b/src/libical/pvl.c @@ -2,18 +2,10 @@ FILE: pvl.c CREATOR: eric November, 1995 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -22,6 +14,8 @@ #include "pvl.h" +#include "icalmemory.h" + #include <assert.h> #include <errno.h> #include <stdlib.h> @@ -80,7 +74,7 @@ pvl_list pvl_newlist() { struct pvl_list_t *L; - if ((L = (struct pvl_list_t *)malloc(sizeof(struct pvl_list_t))) == 0) { + if ((L = (struct pvl_list_t *)icalmemory_new_buffer(sizeof(struct pvl_list_t))) == 0) { errno = ENOMEM; return 0; } @@ -102,7 +96,7 @@ void pvl_free(pvl_list l) pvl_clear(l); - free(L); + icalmemory_free_buffer(L); } /** @@ -124,7 +118,7 @@ pvl_elem pvl_new_element(void *d, pvl_elem next, pvl_elem prior) { struct pvl_elem_t *E; - if ((E = (struct pvl_elem_t *)malloc(sizeof(struct pvl_elem_t))) == 0) { + if ((E = (struct pvl_elem_t *)icalmemory_new_buffer(sizeof(struct pvl_elem_t))) == 0) { errno = ENOMEM; return 0; } @@ -275,7 +269,7 @@ void pvl_insert_ordered(pvl_list L, pvl_comparef f, void *d) /* badness, choke */ #if !defined(lint) - assert(0); + icalassert(0); #endif } @@ -384,7 +378,7 @@ void *pvl_remove(pvl_list L, pvl_elem E) E->next = 0; E->d = 0; - free(E); + icalmemory_free_buffer(E); return data; } diff --git a/src/libical/pvl.h b/src/libical/pvl.h index 50feef16..50369ef3 100644 --- a/src/libical/pvl.h +++ b/src/libical/pvl.h @@ -2,18 +2,10 @@ FILE: pvl.h CREATOR: eric November, 1995 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICAL_PVL_H diff --git a/src/libical/qsort_gen.c b/src/libical/qsort_gen.c index 02f012ed..556eb683 100644 --- a/src/libical/qsort_gen.c +++ b/src/libical/qsort_gen.c @@ -1,16 +1,7 @@ /*====================================================================== FILE: qsort_gen.c - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The code in this file was initially authored as part of the PDCLib project and placed in the public domain. The initial copyright notice was as follows: diff --git a/src/libical/qsort_gen.h b/src/libical/qsort_gen.h index 5f979532..32532127 100644 --- a/src/libical/qsort_gen.h +++ b/src/libical/qsort_gen.h @@ -1,18 +1,9 @@ /*====================================================================== FILE: qsort_gen.h - (C) COPYRIGHT 2018, Markus Minichmayr <markus@tapkey.com> + SPDX-FileCopyrightText: 2018, Markus Minichmayr <markus@tapkey.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Markus Minichmayr. ======================================================================*/ @@ -31,7 +22,6 @@ /** * @brief Sort an arbitrary list of items using the qsort algorithm. - * @param context A pointer representing the list to be sorted. Won't be * interpreted by this function but passed to the compar and swapr functions. * @param nitems The number of items in the list. * @param compar The comparator function. The function receives the pointer diff --git a/src/libical/sspm.c b/src/libical/sspm.c index 0174d23b..e05d22f7 100644 --- a/src/libical/sspm.c +++ b/src/libical/sspm.c @@ -2,29 +2,9 @@ FILE: sspm.c Parse Mime CREATOR: eric 25 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ - - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ @@ -35,6 +15,8 @@ #include "sspm.h" +#include "icalmemory.h" + #include <assert.h> #include <ctype.h> #include <stdlib.h> @@ -136,7 +118,7 @@ static char *sspm_strdup(const char *str) { char *s; - s = strdup(str); + s = icalmemory_strdup(str); return s; } @@ -397,7 +379,7 @@ static struct sspm_action_map get_action(struct mime_impl *impl, return sspm_action_map[i]; } } - assert(i < len); /*should return before now */ + icalassert(i < len); /*should return before now */ return sspm_action_map[0]; } @@ -426,11 +408,11 @@ static enum sspm_major_type sspm_find_major_content_type(char *type) for (i = 0; major_content_type_map[i].type != SSPM_UNKNOWN_MAJOR_TYPE; i++) { if (strncmp(ltype, major_content_type_map[i].str, strlen(major_content_type_map[i].str)) == 0) { - free(ltype); + icalmemory_free_buffer(ltype); return major_content_type_map[i].type; } } - free(ltype); + icalmemory_free_buffer(ltype); return major_content_type_map[i].type; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ } @@ -442,7 +424,7 @@ static enum sspm_minor_type sspm_find_minor_content_type(char *type) char *p = strchr(ltype, '/'); if (p == 0) { - free(ltype); + icalmemory_free_buffer(ltype); return SSPM_UNKNOWN_MINOR_TYPE; } @@ -450,12 +432,12 @@ static enum sspm_minor_type sspm_find_minor_content_type(char *type) for (i = 0; minor_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE; i++) { if (strncmp(p, minor_content_type_map[i].str, strlen(minor_content_type_map[i].str)) == 0) { - free(ltype); + icalmemory_free_buffer(ltype); return minor_content_type_map[i].type; } } - free(ltype); + icalmemory_free_buffer(ltype); return minor_content_type_map[i].type; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ } @@ -523,7 +505,7 @@ static void sspm_build_header(struct sspm_header *header, char *line) char *p = strchr(val, '/'); if (header->minor_text != 0) { - free(header->minor_text); + icalmemory_free_buffer(header->minor_text); } if (p != 0) { p++; /* Skip the '/' */ @@ -536,7 +518,7 @@ static void sspm_build_header(struct sspm_header *header, char *line) } if (boundary != 0) { if (header->boundary != 0) { - free(header->boundary); + icalmemory_free_buffer(header->boundary); } header->boundary = sspm_strdup(boundary); } @@ -559,7 +541,7 @@ static void sspm_build_header(struct sspm_header *header, char *line) header->encoding = SSPM_UNKNOWN_ENCODING; } - free(lencoding); + icalmemory_free_buffer(lencoding); header->def = 0; @@ -567,13 +549,13 @@ static void sspm_build_header(struct sspm_header *header, char *line) char *cid = sspm_value(line); if (header->content_id != 0) { - free(header->content_id); + icalmemory_free_buffer(header->content_id); } header->content_id = sspm_strdup(cid); header->def = 0; } - free(val); - free(prop); + icalmemory_free_buffer(val); + icalmemory_free_buffer(prop); } static char *sspm_get_next_line(struct mime_impl *impl) @@ -603,7 +585,7 @@ static void sspm_set_error(struct sspm_header *header, enum sspm_error error, ch header->error = error; if (header->error_text != 0) { - free(header->error_text); + icalmemory_free_buffer(header->error_text); } header->def = 0; @@ -652,7 +634,7 @@ static void sspm_read_header(struct mime_impl *impl, struct sspm_header *header) impl->state = IN_HEADER; current_line++; - assert(strlen(buf) < TMP_BUF_SIZE); + icalassert(strlen(buf) < TMP_BUF_SIZE); strncpy(header_lines[current_line], buf, TMP_BUF_SIZE); header_lines[current_line][TMP_BUF_SIZE - 1] = '\0'; @@ -684,7 +666,7 @@ static void sspm_read_header(struct mime_impl *impl, struct sspm_header *header) buf_start++; } - assert(strlen(buf_start) + strlen(last_line) < TMP_BUF_SIZE); + icalassert(strlen(buf_start) + strlen(last_line) < TMP_BUF_SIZE); strncat(last_line, buf_start, TMP_BUF_SIZE - strlen(last_line) - 1); @@ -742,8 +724,8 @@ static void sspm_make_part(struct mime_impl *impl, sspm_set_error(header, SSPM_UNEXPECTED_BOUNDARY_ERROR, line); /* Read until the paired terminating boundary */ - if ((boundary = (char *)malloc(strlen(line) + 5)) == 0) { - fprintf(stderr, "Out of memory"); + if ((boundary = (char *)icalmemory_new_buffer(strlen(line) + 5)) == 0) { + icalerrprintf("Out of memory"); abort(); } strcpy(boundary, line); @@ -754,7 +736,7 @@ static void sspm_make_part(struct mime_impl *impl, break; } } - free(boundary); + icalmemory_free_buffer(boundary); break; } @@ -780,8 +762,8 @@ static void sspm_make_part(struct mime_impl *impl, sspm_set_error(parent_header, SSPM_WRONG_BOUNDARY_ERROR, msg); /* Read until the paired terminating boundary */ - if ((boundary = (char *)malloc(strlen(line) + 5)) == 0) { - fprintf(stderr, "Out of memory"); + if ((boundary = (char *)icalmemory_new_buffer(strlen(line) + 5)) == 0) { + icalerrprintf("Out of memory"); abort(); } strcpy(boundary, line); @@ -791,7 +773,7 @@ static void sspm_make_part(struct mime_impl *impl, break; } } - free(boundary); + icalmemory_free_buffer(boundary); } } else { char *data = 0; @@ -799,8 +781,8 @@ static void sspm_make_part(struct mime_impl *impl, *size = strlen(line); - data = (char *)malloc(*size + 2); - assert(data != 0); + data = (char *)icalmemory_new_buffer(*size + 2); + icalassert(data != 0); if (header->encoding == SSPM_BASE64_ENCODING) { rtrn = decode_base64(data, line, size); } else if (header->encoding == SSPM_QUOTED_PRINTABLE_ENCODING) { @@ -818,7 +800,7 @@ static void sspm_make_part(struct mime_impl *impl, action.add_line(part, header, data, *size); - free(data); + icalmemory_free_buffer(data); } } @@ -880,7 +862,7 @@ static void *sspm_make_multipart_subpart(struct mime_impl *impl, struct sspm_hea while ((line = sspm_get_next_line(impl)) != 0) { if (sspm_is_mime_boundary(line)) { - assert(parent_header != 0); + icalassert(parent_header != 0); /* Check if it is the right boundary */ if (!sspm_is_mime_terminating_boundary(line) && @@ -899,8 +881,8 @@ static void *sspm_make_multipart_subpart(struct mime_impl *impl, struct sspm_hea sspm_set_error(parent_header, SSPM_WRONG_BOUNDARY_ERROR, msg); /* Read until the paired terminating boundary */ - if ((boundary = (char *)malloc(strlen(line) + 5)) == 0) { - fprintf(stderr, "Out of memory"); + if ((boundary = (char *)icalmemory_new_buffer(strlen(line) + 5)) == 0) { + icalerrprintf("Out of memory"); abort(); } strcpy(boundary, line); @@ -910,7 +892,7 @@ static void *sspm_make_multipart_subpart(struct mime_impl *impl, struct sspm_hea break; } } - free(boundary); + icalmemory_free_buffer(boundary); return 0; } @@ -1024,22 +1006,22 @@ int sspm_parse_mime(struct sspm_part *parts, static void sspm_free_header(struct sspm_header *header) { if (header->boundary != 0) { - free(header->boundary); + icalmemory_free_buffer(header->boundary); } if (header->minor_text != 0) { - free(header->minor_text); + icalmemory_free_buffer(header->minor_text); } if (header->charset != 0) { - free(header->charset); + icalmemory_free_buffer(header->charset); } if (header->filename != 0) { - free(header->filename); + icalmemory_free_buffer(header->filename); } if (header->content_id != 0) { - free(header->content_id); + icalmemory_free_buffer(header->content_id); } if (header->error_text != 0) { - free(header->error_text); + icalmemory_free_buffer(header->error_text); } } @@ -1142,7 +1124,7 @@ char *decode_base64(char *dest, char *src, size_t *size) cc = -1; } - assert(cc < 64); + icalassert(cc < 64); /* If we've reached the end, fill the remaining slots in the bucket and do a final conversion */ @@ -1226,7 +1208,7 @@ static void sspm_append_char(struct sspm_buffer *buf, char ch) buf->buf_size = (buf->buf_size) * 2 + final_length + 1; - new_buf = realloc(buf->buffer, buf->buf_size); + new_buf = icalmemory_resize_buffer(buf->buffer, buf->buf_size); new_pos = (void *)((size_t) new_buf + data_length); @@ -1255,7 +1237,7 @@ void sspm_append_string(struct sspm_buffer *buf, const char *string) buf->buf_size = (buf->buf_size) * 2 + final_length; - new_buf = realloc(buf->buffer, buf->buf_size); + new_buf = icalmemory_resize_buffer(buf->buffer, buf->buf_size); new_pos = (void *)((size_t) new_buf + data_length); @@ -1350,7 +1332,7 @@ static void sspm_write_base64(struct sspm_buffer *buf, char *inbuf, int size) break; default: - assert(0); + icalassert(0); } for (i = 0; i < 4; i++) { @@ -1385,7 +1367,7 @@ static void sspm_encode_base64(struct sspm_buffer *buf, char *data, size_t size) inbuf[0] = inbuf[1] = inbuf[2] = 0; } - assert(lpos % 4 == 0); + icalassert(lpos % 4 == 0); if (lpos == 72) { sspm_append_string(buf, "\n"); @@ -1423,7 +1405,7 @@ static void sspm_write_header(struct sspm_buffer *buf, struct sspm_header *heade minor = sspm_minor_type_string(header->minor); if (header->minor == SSPM_UNKNOWN_MINOR_TYPE) { - assert(header->minor_text != 0); + icalassert(header->minor_text != 0); minor = header->minor_text; } @@ -1471,7 +1453,7 @@ static void sspm_write_part(struct sspm_buffer *buf, struct sspm_part *part, int } if (part->header.encoding == SSPM_BASE64_ENCODING) { - assert(part->data_size != 0); + icalassert(part->data_size != 0); sspm_encode_base64(buf, part->data, part->data_size); } else if (part->header.encoding == SSPM_QUOTED_PRINTABLE_ENCODING) { sspm_encode_quoted_printable(buf, part->data); @@ -1499,7 +1481,7 @@ static void sspm_write_multipart_part(struct sspm_buffer *buf, while (parts[*part_num].header.major != SSPM_NO_MAJOR_TYPE && level == parent_level + 1) { - assert(header->boundary != NULL); + icalassert(header->boundary != NULL); sspm_append_string(buf, header->boundary); sspm_append_char(buf, '\n'); @@ -1529,7 +1511,7 @@ int sspm_write_mime(struct sspm_part *parts, size_t num_parts, _unused(num_parts); - buf.buffer = malloc(4096); + buf.buffer = icalmemory_new_buffer(4096); buf.buffer[0] = '\0'; buf.pos = buf.buffer; buf.buf_size = 10; diff --git a/src/libical/sspm.h b/src/libical/sspm.h index 6a98e812..0247babe 100644 --- a/src/libical/sspm.h +++ b/src/libical/sspm.h @@ -2,31 +2,11 @@ FILE: sspm.h Mime Parser CREATOR: eric 25 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ - - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom + The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ #ifndef ICAL_SSPM_H diff --git a/src/libical/vcomponent_cxx.cpp b/src/libical/vcomponent_cxx.cpp index 79a67b26..0b42145c 100644 --- a/src/libical/vcomponent_cxx.cpp +++ b/src/libical/vcomponent_cxx.cpp @@ -3,18 +3,10 @@ * @author fnguyen (12/10/01) * @brief Implementation of C++ Wrapper for icalcomponent.c * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #ifdef HAVE_CONFIG_H diff --git a/src/libical/vcomponent_cxx.h b/src/libical/vcomponent_cxx.h index 62c065c8..677d7568 100644 --- a/src/libical/vcomponent_cxx.h +++ b/src/libical/vcomponent_cxx.h @@ -3,18 +3,10 @@ * @author fnguyen (12/10/01) * @brief C++ classes for the icalcomponent wrapper (VToDo VEvent, etc..). * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #ifndef ICAL_VCOMPONENT_CXX_H diff --git a/src/libicalss/CMakeLists.txt b/src/libicalss/CMakeLists.txt index c555eac1..b712e24d 100644 --- a/src/libicalss/CMakeLists.txt +++ b/src/libicalss/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + add_definitions(-Dlibical_icalss_EXPORTS) include_directories( @@ -23,6 +26,7 @@ endif() add_custom_target( icalss-header ALL DEPENDS ${CMAKE_BINARY_DIR}/src/libicalss/icalss.h + COMMENT "Target to generate the aggregate libicalss header" ) ########### next target ############### @@ -83,6 +87,7 @@ add_custom_command( -DBDB_FOUND=${BDB_FOUND} -P ${CMAKE_CURRENT_SOURCE_DIR}/icalss_file.cmake DEPENDS ${icalss_LIB_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/icalss_file.cmake + COMMENT "Generate the aggregate libicalss header" ) add_library(icalss ${LIBRARY_TYPE} ${icalss_LIB_SRCS}) @@ -151,7 +156,10 @@ if(WITH_CXX_BINDINGS) add_library(icalss_cxx-static ALIAS icalss_cxx) endif() - target_link_libraries(icalss_cxx icalss ical_cxx ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(icalss_cxx icalss ical_cxx) + if(DEFINED CMAKE_THREAD_LIBS_INIT) + target_link_libraries(icalss_cxx ${CMAKE_THREAD_LIBS_INIT}) + endif() if(MSVC) set_target_properties(icalss_cxx PROPERTIES PREFIX "lib") diff --git a/src/libicalss/icalbdbset.c b/src/libicalss/icalbdbset.c index 9af2674c..e8a4f206 100644 --- a/src/libicalss/icalbdbset.c +++ b/src/libicalss/icalbdbset.c @@ -1,18 +1,10 @@ /*====================================================================== FILE: icalbdbset.c - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -31,8 +23,16 @@ #define MAX_RETRY 5 +#if !defined(DB_VERSION_MAJOR) +#define DB_VERSION_MAJOR 1 //assume ancient version +#endif + static int _compare_ids(const char *compid, const char *matchid); +#if DB_VERSION_MAJOR > 5 +static int _compare_keys(DB *dbp, const DBT *a, const DBT *b, size_t *locp); +#else static int _compare_keys(DB *dbp, const DBT *a, const DBT *b); +#endif /** Default options used when NULL is passed to icalset_new() **/ static icalbdbset_options icalbdbset_options_default = @@ -75,7 +75,11 @@ int icalbdbset_init_dbenv(char *db_env_dir, flags = (u_int32_t) (DB_INIT_LOCK | DB_INIT_TXN | DB_CREATE | DB_THREAD | DB_RECOVER | DB_INIT_LOG | DB_INIT_MPOOL); +#if defined(_WIN32) //krazy:exclude=cpp + ret = ICAL_DB_ENV->open(ICAL_DB_ENV, db_env_dir, flags, 0 /*ignored on Windows*/); +#else ret = ICAL_DB_ENV->open(ICAL_DB_ENV, db_env_dir, flags, S_IRUSR | S_IWUSR); +#endif if (ret) { /*char *foo = db_strerror(ret); */ @@ -1598,7 +1602,11 @@ int icalbdbset_commit_transaction(DB_TXN *txnid) return txnid->commit(txnid, 0); } +#if DB_VERSION_MAJOR > 5 +static int _compare_keys(DB *dbp, const DBT *a, const DBT *b, size_t *locp) +#else static int _compare_keys(DB *dbp, const DBT *a, const DBT *b) +#endif { /* * Returns: @@ -1611,5 +1619,8 @@ static int _compare_keys(DB *dbp, const DBT *a, const DBT *b) char *bc = (char *)b->data; _unused(dbp); +#if DB_VERSION_MAJOR > 5 + locp = NULL; +#endif return strncmp(ac, bc, a->size); } diff --git a/src/libicalss/icalbdbset.h b/src/libicalss/icalbdbset.h index 1fe2e2cf..079ae393 100644 --- a/src/libicalss/icalbdbset.h +++ b/src/libicalss/icalbdbset.h @@ -1,18 +1,10 @@ /*====================================================================== FILE: icalbdbset.h - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALBDBSET_H diff --git a/src/libicalss/icalbdbset_cxx.h b/src/libicalss/icalbdbset_cxx.h index 976d0d2f..1f676b89 100644 --- a/src/libicalss/icalbdbset_cxx.h +++ b/src/libicalss/icalbdbset_cxx.h @@ -3,18 +3,9 @@ * @author dml 12/12/01 * @brief Definition of C++ Wrapper for icalbdbset.c * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifndef ICALBDBSET_CXX_H diff --git a/src/libicalss/icalbdbsetimpl.h b/src/libicalss/icalbdbsetimpl.h index a5a60a47..a88df55e 100644 --- a/src/libicalss/icalbdbsetimpl.h +++ b/src/libicalss/icalbdbsetimpl.h @@ -1,18 +1,10 @@ /*====================================================================== FILE: icalbdbsetimpl.h - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALBDBSETIMPL_H diff --git a/src/libicalss/icalcalendar.c b/src/libicalss/icalcalendar.c index 5d50f121..61130efd 100644 --- a/src/libicalss/icalcalendar.c +++ b/src/libicalss/icalcalendar.c @@ -2,18 +2,10 @@ FILE: icalcalendar.c CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H diff --git a/src/libicalss/icalcalendar.h b/src/libicalss/icalcalendar.h index ac424be0..4cf005cc 100644 --- a/src/libicalss/icalcalendar.h +++ b/src/libicalss/icalcalendar.h @@ -2,18 +2,9 @@ FILE: icalcalendar.h CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalclassify.c b/src/libicalss/icalclassify.c index 00e72fed..7450d8d1 100644 --- a/src/libicalss/icalclassify.c +++ b/src/libicalss/icalclassify.c @@ -2,18 +2,10 @@ FILE: icalclassify.c CREATOR: ebusboom 23 aug 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -49,7 +41,7 @@ char *icalclassify_lowercase(const char *str) return 0; } - xnew = icalmemory_strdup(str); + xnew = strdup(str); for (p = xnew; *p != 0; p++) { *p = tolower((int)*p); } @@ -292,8 +284,8 @@ int icalssutil_is_rescheduled(icalcomponent *a, icalcomponent *b) temp1 = icalproperty_as_ical_string_r(p1); temp2 = icalproperty_as_ical_string_r(p2); cmp = strcmp(temp1, temp2); - free(temp1); - free(temp2); + icalmemory_free_buffer(temp1); + icalmemory_free_buffer(temp2); if (p1 && cmp != 0) { return 1; diff --git a/src/libicalss/icalclassify.h b/src/libicalss/icalclassify.h index 04b1e237..1d39a057 100644 --- a/src/libicalss/icalclassify.h +++ b/src/libicalss/icalclassify.h @@ -2,18 +2,10 @@ FILE: icalclassify.h CREATOR: eric 21 Aug 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ =========================================================================*/ #ifndef ICALCLASSIFY_H diff --git a/src/libicalss/icalcluster.c b/src/libicalss/icalcluster.c index ee926701..27861fe8 100644 --- a/src/libicalss/icalcluster.c +++ b/src/libicalss/icalcluster.c @@ -2,18 +2,10 @@ FILE: icalcluster.c CREATOR: acampi 13 March 2002 - Copyright (C) 2002 Andrea Campi <a.campi@inet.it> + SPDX-FileCopyrightText: 2002 Andrea Campi <a.campi@inet.it> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /** diff --git a/src/libicalss/icalcluster.h b/src/libicalss/icalcluster.h index 1514a440..31195bb0 100644 --- a/src/libicalss/icalcluster.h +++ b/src/libicalss/icalcluster.h @@ -2,18 +2,10 @@ FILE: icalcluster.h CREATOR: acampi 13 March 2002 - Copyright (C) 2002 Andrea Campi <a.campi@inet.it> + SPDX-FileCopyrightText: 2002 Andrea Campi <a.campi@inet.it> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALCLUSTER_H diff --git a/src/libicalss/icalclusterimpl.h b/src/libicalss/icalclusterimpl.h index e0cea3dd..642827fd 100644 --- a/src/libicalss/icalclusterimpl.h +++ b/src/libicalss/icalclusterimpl.h @@ -2,18 +2,10 @@ FILE: icalfilesetimpl.h CREATOR: acampi 13 March 2002 - Copyright (C) 2002 Andrea Campi <a.campi@inet.it> + SPDX-FileCopyrightText: 2002 Andrea Campi <a.campi@inet.it> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALCLUSTERIMPL_H diff --git a/src/libicalss/icaldirset.c b/src/libicalss/icaldirset.c index 02c08667..eecf22e4 100644 --- a/src/libicalss/icaldirset.c +++ b/src/libicalss/icaldirset.c @@ -3,18 +3,9 @@ FILE: icaldirset.c CREATOR: eric 28 November 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icaldirset.h b/src/libicalss/icaldirset.h index d3c3e35e..edab10e2 100644 --- a/src/libicalss/icaldirset.h +++ b/src/libicalss/icaldirset.h @@ -2,18 +2,9 @@ FILE: icaldirset.h CREATOR: eric 28 November 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icaldirsetimpl.h b/src/libicalss/icaldirsetimpl.h index 800e987d..2c0f5ecf 100644 --- a/src/libicalss/icaldirsetimpl.h +++ b/src/libicalss/icaldirsetimpl.h @@ -2,18 +2,9 @@ FILE: icaldirsetimpl.h CREATOR: eric 21 Aug 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalfileset.c b/src/libicalss/icalfileset.c index 6085c23c..2778025c 100644 --- a/src/libicalss/icalfileset.c +++ b/src/libicalss/icalfileset.c @@ -2,18 +2,9 @@ FILE: icalfileset.c CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -27,6 +18,7 @@ #include "icalfilesetimpl.h" #include "icalparser.h" #include "icalvalue.h" +#include "icalmemory.h" #include <errno.h> #include <stdlib.h> @@ -397,11 +389,11 @@ icalerrorenum icalfileset_commit(icalset *set) if (sz != (IO_SSIZE_T) strlen(str)) { perror("write"); icalerror_set_errno(ICAL_FILE_ERROR); - free(str); + icalmemory_free_buffer(str); return ICAL_FILE_ERROR; } - free(str); + icalmemory_free_buffer(str); write_size += sz; } diff --git a/src/libicalss/icalfileset.h b/src/libicalss/icalfileset.h index 23060e34..04de522d 100644 --- a/src/libicalss/icalfileset.h +++ b/src/libicalss/icalfileset.h @@ -2,18 +2,9 @@ FILE: icalfileset.h CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalfilesetimpl.h b/src/libicalss/icalfilesetimpl.h index 6d7ffeab..b2bb72e2 100644 --- a/src/libicalss/icalfilesetimpl.h +++ b/src/libicalss/icalfilesetimpl.h @@ -2,18 +2,9 @@ FILE: icalfilesetimpl.h CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalgauge.c b/src/libicalss/icalgauge.c index 65d8b854..73390f85 100644 --- a/src/libicalss/icalgauge.c +++ b/src/libicalss/icalgauge.c @@ -2,18 +2,9 @@ FILE: icalgauge.c CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalgauge.h b/src/libicalss/icalgauge.h index be6c7440..ee07952a 100644 --- a/src/libicalss/icalgauge.h +++ b/src/libicalss/icalgauge.h @@ -2,18 +2,9 @@ FILE: icalgauge.h CREATOR: eric 23 December 1999 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalgaugeimpl.h b/src/libicalss/icalgaugeimpl.h index 3b07240e..a9423162 100644 --- a/src/libicalss/icalgaugeimpl.h +++ b/src/libicalss/icalgaugeimpl.h @@ -2,18 +2,10 @@ FILE: icalgaugeimpl.h CREATOR: eric 09 Aug 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALGAUGEIMPL_H diff --git a/src/libicalss/icalmessage.c b/src/libicalss/icalmessage.c index d9a7f2a9..779d41d9 100644 --- a/src/libicalss/icalmessage.c +++ b/src/libicalss/icalmessage.c @@ -2,18 +2,10 @@ FILE: icalmessage.c CREATOR: ebusboom 07 Nov 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -22,7 +14,6 @@ #include "icalmessage.h" #include "icalerror.h" -#include "icalmemory.h" #include "icalversion.h" /* for ICAL_PACKAGE, ICAL_VERSION */ #include <ctype.h> @@ -46,7 +37,7 @@ static char *lowercase(const char *str) return 0; } - n = icalmemory_strdup(str); + n = strdup(str); for (p = n; *p != 0; p++) { *p = tolower((int)*p); diff --git a/src/libicalss/icalmessage.h b/src/libicalss/icalmessage.h index 7ec629bf..20aee462 100644 --- a/src/libicalss/icalmessage.h +++ b/src/libicalss/icalmessage.h @@ -2,18 +2,10 @@ FILE: icalmessage.h CREATOR: eric 07 Nov 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ =========================================================================*/ #ifndef ICALMESSAGE_H diff --git a/src/libicalss/icalset.c b/src/libicalss/icalset.c index 674e05b4..b98f233f 100644 --- a/src/libicalss/icalset.c +++ b/src/libicalss/icalset.c @@ -2,7 +2,7 @@ FILE: icalset.c CREATOR: eric 17 Jul 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> Icalset is the "base class" for representations of a collection of iCal components. Derived classes (actually delegates) include: @@ -12,16 +12,7 @@ icalheapset Store components on the heap icalmysqlset Store components in a mysql database. - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalset.h b/src/libicalss/icalset.h index 23e677d8..00011e35 100644 --- a/src/libicalss/icalset.h +++ b/src/libicalss/icalset.h @@ -14,18 +14,9 @@ /* - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/libicalss/icalspanlist.c b/src/libicalss/icalspanlist.c index a0f40ef6..027777c8 100644 --- a/src/libicalss/icalspanlist.c +++ b/src/libicalss/icalspanlist.c @@ -2,18 +2,10 @@ FILE: icalspanlist.c CREATOR: ebusboom 23 aug 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -189,22 +181,22 @@ icalspanlist *icalspanlist_new(icalset *set, struct icaltimetype start, struct i return sl; } -void icalspanlist_free(icalspanlist *s) +void icalspanlist_free(icalspanlist *sl) { struct icaltime_span *span; - if (s == NULL) + if (sl == NULL) return; - while ((span = pvl_pop(s->spans)) != 0) { + while ((span = pvl_pop(sl->spans)) != 0) { free(span); } - pvl_free(s->spans); + pvl_free(sl->spans); - s->spans = 0; + sl->spans = 0; - free(s); + free(sl); } void icalspanlist_dump(icalspanlist *sl) @@ -215,8 +207,8 @@ void icalspanlist_dump(icalspanlist *sl) for (itr = pvl_head(sl->spans); itr != 0; itr = pvl_next(itr)) { struct icaltime_span *s = (struct icaltime_span *)pvl_data(itr); if (s) { - printf("#%02d %d start: %s", ++i, s->is_busy, ctime(&s->start)); - printf(" end : %s", ctime(&s->end)); + printf("#%02d %d start: %s", ++i, s->is_busy, icalctime(&s->start)); + printf(" end : %s", icalctime(&s->end)); } } } @@ -229,7 +221,7 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist *sl, struct icalt struct icalperiodtype period; struct icaltime_span *s; - time_t rangett = icaltime_as_timet(t); + icaltime_t rangett = icaltime_as_timet(t); period.start = icaltime_null_time(); period.end = icaltime_null_time(); @@ -290,17 +282,17 @@ struct icalperiodtype icalspanlist_next_free_time(icalspanlist *sl, struct icalt int *icalspanlist_as_freebusy_matrix(icalspanlist *sl, int delta_t) { pvl_elem itr; - time_t spanduration_secs; + icaltime_t spanduration_secs; int *matrix; - time_t matrix_slots; - time_t sl_start, sl_end; + icaltime_t matrix_slots; + icaltime_t sl_start, sl_end; icalerror_check_arg_rz((sl != 0), "spanlist"); if (!delta_t) delta_t = 3600; - /* calculate the start and end time as time_t **/ + /* calculate the start and end time as icaltime_t **/ sl_start = icaltime_as_timet_with_zone(sl->start, icaltimezone_get_utc_timezone()); sl_end = icaltime_as_timet_with_zone(sl->end, icaltimezone_get_utc_timezone()); @@ -333,9 +325,9 @@ int *icalspanlist_as_freebusy_matrix(icalspanlist *sl, int delta_t) struct icaltime_span *s = (struct icaltime_span *)pvl_data(itr); if (s && s->is_busy == 1) { - time_t offset_start = s->start / delta_t - sl_start / delta_t; - time_t offset_end = (s->end - 1) / delta_t - sl_start / delta_t + 1; - time_t i; + icaltime_t offset_start = s->start / delta_t - sl_start / delta_t; + icaltime_t offset_end = (s->end - 1) / delta_t - sl_start / delta_t + 1; + icaltime_t i; if (offset_end >= matrix_slots) offset_end = matrix_slots - 1; diff --git a/src/libicalss/icalspanlist.h b/src/libicalss/icalspanlist.h index c5b44cd1..edd43605 100644 --- a/src/libicalss/icalspanlist.h +++ b/src/libicalss/icalspanlist.h @@ -2,18 +2,10 @@ FILE: icalspanlist.h CREATOR: eric 21 Aug 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ =========================================================================*/ #ifndef ICALSPANLIST_H #define ICALSPANLIST_H @@ -44,11 +36,11 @@ LIBICAL_ICALSS_EXPORT icalspanlist *icalspanlist_new(icalset *set, struct icaltimetype end); /** @brief Destructor. - * @param s A valid icalspanlist + * @param sl A valid icalspanlist * * Frees the memory associated with the spanlist. */ -LIBICAL_ICALSS_EXPORT void icalspanlist_free(icalspanlist *spl); +LIBICAL_ICALSS_EXPORT void icalspanlist_free(icalspanlist *sl); /** @brief Finds the next free time span in a spanlist. * @@ -64,7 +56,7 @@ LIBICAL_ICALSS_EXPORT struct icalperiodtype icalspanlist_next_free_time(icalspan /** @brief (Debug) print out spanlist to STDOUT. * @param sl A valid icalspanlist. */ -LIBICAL_ICALSS_EXPORT void icalspanlist_dump(icalspanlist *s); +LIBICAL_ICALSS_EXPORT void icalspanlist_dump(icalspanlist *sl); /** @brief Returns a VFREEBUSY component for a spanlist. * @@ -87,7 +79,7 @@ LIBICAL_ICALSS_EXPORT icalcomponent *icalspanlist_as_vfreebusy(icalspanlist *sl, /** @brief Returns an hour-by-hour array of free/busy times over a * given period. * - * @param sl A valid icalspanlist + * @param span A valid icalspanlist * @param delta_t The time slice to divide by, in seconds. Default 3600. * * @return A pointer to an array of integers containing the number of diff --git a/src/libicalss/icalspanlist_cxx.cpp b/src/libicalss/icalspanlist_cxx.cpp index 4f72eb50..00967518 100644 --- a/src/libicalss/icalspanlist_cxx.cpp +++ b/src/libicalss/icalspanlist_cxx.cpp @@ -4,18 +4,10 @@ * @brief C++ class wrapping the icalspanlist data structure * - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #include "icalspanlist_cxx.h" diff --git a/src/libicalss/icalspanlist_cxx.h b/src/libicalss/icalspanlist_cxx.h index 1698133e..775a6d9f 100644 --- a/src/libicalss/icalspanlist_cxx.h +++ b/src/libicalss/icalspanlist_cxx.h @@ -3,18 +3,9 @@ * @author Critical Path * @brief C++ class wrapping the icalspanlist data structure * - * (C) COPYRIGHT 2001, Critical Path + * SPDX-FileCopyrightText: 2001, Critical Path * - * This library is free software; you can redistribute it and/or modify - * it under the terms of either: - * - * The LGPL as published by the Free Software Foundation, version - * 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - * - * Or: - * - * The Mozilla Public License Version 2.0. You may obtain a copy of - * the License at https://www.mozilla.org/MPL/ + * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ #ifndef ICALSPANLIST_CXX_H diff --git a/src/libicalss/icalss_file.cmake b/src/libicalss/icalss_file.cmake index df105627..8983e380 100644 --- a/src/libicalss/icalss_file.cmake +++ b/src/libicalss/icalss_file.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + # ORDERING OF HEADERS IS SIGNIFICANT. Don't change this ordering. # It is required to make the combined header icalss.h properly. set(COMBINEDHEADERSICALSS diff --git a/src/libicalss/icalsslexer.l b/src/libicalss/icalsslexer.l index bb5b5c09..b06fe35a 100644 --- a/src/libicalss/icalsslexer.l +++ b/src/libicalss/icalsslexer.l @@ -4,18 +4,9 @@ FILE: icalsslexer.l CREATOR: eric 8 Aug 2000 -(C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom @@ -24,24 +15,28 @@ #include "icalssyacc.h" #include "icalgaugeimpl.h" +#include "icalmemory.h" #include "assert.h" YYSTYPE sslval; -const char* input_buffer; -const char* input_buffer_p; +const char *input_buffer; +const char *input_buffer_p; -int icalss_input(char* buf, int max_size) +int icalss_input(const char *buf, int max_size) { int n; int l; l = strlen(input_buffer_p); - if (max_size<l) n = max_size; - else n = l; + if (max_size < l) { + n = max_size; + } else { + n = l; + } - if (n > 0){ - memcpy(buf, input_buffer_p, n); + if (n > 0) { + memcpy((void *)buf, input_buffer_p, n); input_buffer_p += n; return n; } else { diff --git a/src/libicalss/icalssyacc.h b/src/libicalss/icalssyacc.h index f97cc4a7..e8592097 100644 --- a/src/libicalss/icalssyacc.h +++ b/src/libicalss/icalssyacc.h @@ -2,8 +2,8 @@ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + SPDX-FileCopyrightText: 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -97,4 +97,3 @@ typedef union YYSTYPE #endif extern YYSTYPE sslval; - diff --git a/src/libicalss/icalssyacc.y b/src/libicalss/icalssyacc.y index ae40f119..6d38adcb 100644 --- a/src/libicalss/icalssyacc.y +++ b/src/libicalss/icalssyacc.y @@ -3,18 +3,9 @@ /* FILE: icalssyacc.y */ /* CREATOR: eric 08 Aug 2000 */ /* */ -/* (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> */ +/* SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> */ /* */ -/* This program is free software; you can redistribute it and/or modify */ -/* it under the terms of either: */ -/* */ -/* The LGPL as published by the Free Software Foundation, version */ -/* 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html */ -/* */ -/* Or: */ -/* */ -/* The Mozilla Public License Version 2.0. You may obtain a copy of */ -/* the License at https://www.mozilla.org/MPL/ */ +/* SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ /* */ /* The Original Code is eric. The Initial Developer of the Original */ /* Code is Eric Busboom */ @@ -36,13 +27,14 @@ extern struct icalgauge_impl *icalss_yy_gauge; #define yyerror sserror -void sserror(char *s); +void sserror(const char *s); +int yylex(void); -static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, - icalgaugecompare compare , char* value); -static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); -static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1); -static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l); +static void ssyacc_add_where(struct icalgauge_impl *impl, char *prop, + icalgaugecompare compare, const char *value); +static void ssyacc_add_select(struct icalgauge_impl *impl, char *str1); +static void ssyacc_add_from(struct icalgauge_impl *impl, char *str1); +static void set_logic(struct icalgauge_impl *impl, icalgaugelogic l); /* Don't know why I need this.... */ @@ -58,7 +50,6 @@ int sslex(void); char* v_string; } - %token <v_string> STRING %token SELECT FROM WHERE COMMA QUOTE EQUALS NOTEQUALS LESS GREATER LESSEQUALS %token GREATEREQUALS AND OR EOL END IS NOT SQLNULL @@ -102,22 +93,21 @@ where_list: | where_list OR where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);} ; - %% -static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, - icalgaugecompare compare , char* value_str) +static void ssyacc_add_where(struct icalgauge_impl *impl, char *str1, + icalgaugecompare compare, const char *value_str) { - struct icalgauge_where *where; - char *compstr, *propstr, *c, *s,*l; + char *compstr, *propstr, *c, *l; + const char *s; - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; + if ((where = malloc(sizeof(struct icalgauge_where))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return; } - memset(where,0,sizeof(struct icalgauge_where)); + memset(where, 0, sizeof(struct icalgauge_where)); where->logic = ICALGAUGELOGIC_NONE; where->compare = ICALGAUGECOMPARE_NONE; where->comp = ICAL_NO_COMPONENT; @@ -125,71 +115,64 @@ static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, /* remove enclosing quotes */ s = value_str; - if(*s == '\''){ - s++; + if (*s == '\'') { + s++; } - l = s+strlen(s)-1; - if(*l == '\''){ - *l=0; + l = (char *)(s + strlen(s) - 1); + if (*l == '\'') { + *l = 0; } where->value = strdup(s); /* Is there a period in str1 ? If so, the string specified both a */ /* component and a property */ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; + if ((c = strrchr(str1, '.')) != 0 ) { + compstr = str1; + propstr = c + 1; + *c = '\0'; } else { - compstr = 0; - propstr = str1; + compstr = 0; + propstr = str1; } - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); + if (compstr != 0) { + where->comp = icalenum_string_to_component_kind(compstr); } else { - where->comp = ICAL_NO_COMPONENT; + where->comp = ICAL_NO_COMPONENT; } - where->prop = icalenum_string_to_property_kind(propstr); - where->compare = compare; - - if(where->value == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(where->value); - return; + if (where->value == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + free(where->value); + return; } - pvl_push(impl->where,where); + pvl_push(impl->where, where); } -static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) +static void set_logic(struct icalgauge_impl *impl, icalgaugelogic l) { pvl_elem e = pvl_tail(impl->where); struct icalgauge_where *where = pvl_data(e); where->logic = l; - } - - -static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) +static void ssyacc_add_select(struct icalgauge_impl *impl, char *str1) { char *c, *compstr, *propstr; struct icalgauge_where *where; /* Uses only the prop and comp fields of the where structure */ - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; + if ((where = malloc(sizeof(struct icalgauge_where))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return; } - memset(where,0,sizeof(struct icalgauge_where)); + memset(where, 0, sizeof(struct icalgauge_where)); where->logic = ICALGAUGELOGIC_NONE; where->compare = ICALGAUGECOMPARE_NONE; where->comp = ICAL_NO_COMPONENT; @@ -197,57 +180,53 @@ static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) /* Is there a period in str1 ? If so, the string specified both a */ /* component and a property */ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; + if ((c = strrchr(str1, '.')) != 0) { + compstr = str1; + propstr = c + 1; + *c = '\0'; } else { - compstr = 0; - propstr = str1; + compstr = 0; + propstr = str1; } - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); + if (compstr != 0) { + where->comp = icalenum_string_to_component_kind(compstr); } else { - where->comp = ICAL_NO_COMPONENT; + where->comp = ICAL_NO_COMPONENT; } - /* If the property was '*', then accept all properties */ - if(strcmp("*",propstr) == 0) { - where->prop = ICAL_ANY_PROPERTY; + if (strcmp("*", propstr) == 0) { + where->prop = ICAL_ANY_PROPERTY; } else { - where->prop = icalenum_string_to_property_kind(propstr); + where->prop = icalenum_string_to_property_kind(propstr); } - - if(where->prop == ICAL_NO_PROPERTY){ - free(where); - icalerror_set_errno(ICAL_BADARG_ERROR); - return; + if (where->prop == ICAL_NO_PROPERTY) { + free(where); + icalerror_set_errno(ICAL_BADARG_ERROR); + return; } - pvl_push(impl->select,where); + pvl_push(impl->select, where); } -static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) +static void ssyacc_add_from(struct icalgauge_impl *impl, char *str1) { icalcomponent_kind ckind; ckind = icalenum_string_to_component_kind(str1); - if(ckind == ICAL_NO_COMPONENT){ - assert(0); + if (ckind == ICAL_NO_COMPONENT) { + assert(0); } - pvl_push(impl->from,(void*)ckind); - + pvl_push(impl->from, (void*)ckind); } - -void sserror(char *s){ - fprintf(stderr,"Parse error \'%s\'\n", s); - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); +void sserror(const char *s) +{ + fprintf(stderr,"Parse error \'%s\'\n", s); + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); } diff --git a/src/libicalss/libical_icalss_export.h b/src/libicalss/libical_icalss_export.h index 9341ad35..e099c6be 100644 --- a/src/libicalss/libical_icalss_export.h +++ b/src/libicalss/libical_icalss_export.h @@ -1,3 +1,8 @@ +/** + SPDX-FileCopyrightText: Allen Winter <winter@kde.org> + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +*/ + #ifndef LIBICAL_ICALSS_EXPORT_H #define LIBICAL_ICALSS_EXPORT_H diff --git a/src/libicalvcal/CMakeLists.txt b/src/libicalvcal/CMakeLists.txt index 80b98ee0..d9caeaf6 100644 --- a/src/libicalvcal/CMakeLists.txt +++ b/src/libicalvcal/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + add_definitions(-Dlibical_vcal_EXPORTS) include_directories( diff --git a/src/libicalvcal/README.TXT b/src/libicalvcal/README.txt index 35e1f9b3..734c30a4 100644 --- a/src/libicalvcal/README.TXT +++ b/src/libicalvcal/README.txt @@ -1,951 +1,959 @@ -NOTE: If you used the earlier APIs released by Versit
-then you will want to look at the document "migrate.doc"
-included with this package. It contains a discussion of
-the differences between the old API and this one.
-
-----------------------------------------------------------------
-
-The vCard/vCalendar C interface is implemented in the set
-of files as follows:
-
-vcc.y, yacc source, and vcc.c, the yacc output you will use
-implements the core parser
-
-vobject.c implements an API that insulates the caller from
-the parser and changes in the vCard/vCalendar BNF
-
-port.h defines compilation environment dependent stuff
-
-vcc.h and vobject.h are header files for their .c counterparts
-
-vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions
-which you may find useful.
-
-test.c is a standalone test driver that exercises some of
-the features of the APIs provided. Invoke test.exe on a
-VCARD/VCALENDAR input text file and you will see the pretty
-print output of the internal representation (this pretty print
-output should give you a good idea of how the internal
-representation looks like -- there is one such output in the
-following too). Also, a file with the .out suffix is generated
-to show that the internal representation can be written back
-in the original text format.
-
------------------------------------------------------------------
-
-
- VObject for VCard/VCalendar
-
-Table of Contents
-=================
-1. VObject
-2. Internal Representations of VCard/VCalendar
-3. Iterating Through VObject's Properties or Values
-4. Pretty Printing a VObject Tree
-5. Building A VObject Representation of A VCard/VCalendar
-6. Converting A VObject Representation Into Its Textual Representation
-7. Miscellaneous Notes On VObject APIs usages
-8. Brief descriptions of each APIs
-9. Additional Programming Notes.
-
-This document is mainly about the VObject and its APIs. The main
-use of a VObject is to represent a VCard or a VCalendar inside
-a program. However, its use is not limited to aforemention as it
-can represent an arbitrary information that makes up of a tree or
-forest of properties/values.
-
-1. VObject
- =======
-A VObject can have a name (id) and a list of associated properties and
-a value. Each property is itself a VObject.
-
-2. Internal Representations of VCard/VCalendar
- ===========================================
-A list of VCard or a VCalendar is represented by a list of VObjects.
-The name (id) of the VObjects in the list is either VCCardProp or
-VCCalProp. Each of these VObjects can have a list of properties.
-Since a property is represented as a VObject, each of these properties
-can have a name, a list of properties, and a value.
-
-For example, the input file "vobject.vcf":
-
-BEGIN:VCARD
-N:Alden;Roland
-FN:Roland H. Alden
-ORG:AT&T;Versit Project Office
-TITLE:Consultant
-EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-EMAIL;INTERNET:ralden@sfgate.com
-EMAIL;MCIMail:242-2200
-LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111
-LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-Suite 2208=0A=
-One Pine Street=0A=
-San Francisco, CA 94111=0A=
-U.S.A.
-TEL;WORK;PREF;MSG:+1 415 296 9106
-TEL;WORK;FAX:+1 415 296 9016
-TEL;MSG;CELL:+1 415 608 5981
-ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-SOUND:ROW-LAND H ALL-DIN
-LOGO;GIF;BASE64:
- R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- QjExMSEhIRAQEO///87v9973/73n95zW71K13jGl1nvG50Kt3iGc1gCMzq3e94zO
- 7xCU1nO952O15wAAACwAAAAApgBOAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zv
- /8CgcEj8QTaeywWTyWCUno2kSK0KI5tLc8vtNi+WiHVMlj0mFK96nalsxOW4fPSw
- cNj4tQc+7xcjGh4WExJTJYUTFkp3eU0eEH6RkpOUlTARhRoWm5ydFpCWoS0QEqAu
- ARKaHRcVjV0borEoFl0cSre4Sq67FA+yvwAeTU8XHZ7HmxS6u2wVfMCVpAE3pJoW
- ylrMptDcOqSF4OHg3eQ5pInInb7lcc86mNbLzBXsZbRfUOn6ucyNHvVWJHCpQFDf
- MWwEEzLqx2YCQCqF3OnItClJNmYcJD7cSAKTuI/gtnEcOQKkyVIk6/+ds5CkFcMM
- 61LiENikwi1jBnNyuvUSjwWZOS5uIZarqNFcNl32XMMB6I06GgoJ+bZp1ZKeDl8E
- +MC1K1cBIhZ4HUu2LAsCZdOWRQDt20lxIlccSHsgrNq7Xc/ixcsWmNu34WKyYJCW
- gQjCe9XqTZy2L4pv04gg2sSKSc8OLgTcBSuWsdkVaD2TdXyiQxebFyjo1Gnx6tJm
- LuaqrdtZtNfFtruSNmF5IKujwIsmJbjwtRqNJhrcNVw79wcRAgogmE4ArIjQzj/s
- JvHAGCFDQR4UqigPK4sBe62XwO51OwADiMcqUG+iOdcFAL+hW20BfAoEexlwAnu6
- mZDAXQ1EVh//WfhxJB5gIbHgwFgOTOiVAgOuVQKAfKFg3weGwSBYFZMp4hpDGKyA
- 3lgJKECWgiMQyBVpW+0V4oJjNfhCNkR1IgWEb21QlRK9GdfFCgeOZYBsXgm4noYj
- GEBhAQHYh0J8XenoQnFGdrkUciJY6FUAK15ogozakcBhliKsyZWHDMZQ0wWC/Aim
- DB6h01KRr/lXQgFxAqDcWDACgCZpUnrVQJtjwTnWjS6MWAYqqfDnSaEkJOlVXQBo
- 2pWTMUJ53WgAuPncCR9q6VQMAYjZlXWJmknCoSUM2p4BC+SaKwG88hoZlvfFMM4f
- hQh5TXkv+RklWYtC91mopJIAKFkJlDAW/wF25ShnLbeo5gmQ+1FGkJdrKCuCi2OR
- BuwHBcwqKgABrMtVAgpem61XkLbAJ7n8uiIpvGVhO4KpH1QLbbpqLheZvQCkGoNL
- thSzSTg2UGVBBzbtaxwKsYrmgLvRAlCmWgwMAADD66rKAgR3XlGspcdkZYK8ibU7
- asgEl+XAyB8I7PCqMWiWncGGimpfAgO4ypXSPpOVLwsRCDJxRD2AoyeRRv5kApO5
- fXwzwvfOKLKtaTWtbQxccmGLTZy8xYlVSvXbhbk0M2YzrYfJJ0K8m+V9NgxpyC04
- UycI/aiuiH9Y8NftDUwWp1Wm5UABnAUKwwRsPFGBt4Oc9PZvGvNLwf8JOZt8Arpe
- eY23yDovwIDiBX74NAsPVLDJj3Hh4JEExsKcjrlKf9DsCVx3ZfLqAKBuG1s/A90C
- z2KjYHjjyPOdG1spz6BBUr+BcUxUb1nDCTa/VZD2Uv+YkLPAKJC9dNEh7628WgqI
- ybzlaA+ufxMa6bxC6ciLUQLcx5UGIAAsAkDA6wQkOxrcY39yo4cQMNWCAPTKV1R4
- wPkgaBxzOc8FtMiF1NoGoXBRJjgoPApmPsjCFlbMdzCM4TFy50IXxI2DPcHAv2rY
- gghsEIeu8CAPW6ABIPYEFkOsAeaMyIz0JfGJUExBBGRIRX0IMYovWCIT1eBELNpA
- i1vcgta8iANPCIQOghzQABl30J0tXqBla4wjFLFQxZzAUY42CIAd5OYBCuKxB2c4
- I0b28EcrQKADgmSKB9RYyDhA4BqCxIBqrtjIMTwoFeCjYSU3KZMQAAA7
-
-BEGIN:VCALENDAR
-DCREATED:19960523T100522
-PRODID:-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN
-VERSION:0.3
-BEGIN:VEVENT
-START:19960523T120000
-END:19960523T130000
-SUBTYPE:PHONE CALL
-SUMMARY:VERSIT PDI PR Teleconference/Interview
-DESCRIPTION:VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland
-END:VEVENT
-BEGIN:VEVENT
-START:19960523T113000
-END:19960523T115500
-SUBTYPE:LUNCH
-SUMMARY:Eat in the cafeteria today
-END:VEVENT
-END:VCALENDAR
-
-END:VCARD
-
-
-will conceptually be represented as
- vcard
- VCNameProp
- VCFamilyNameProp=Alden
- VCGivenNameProp=Roland
- VCFullNameProp=Roland H.Alden
- ....
-
-note that
- EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com
-will be represented as:
- VCEmailAddress=sf!rincon!ralden@alden.attmail.com
- VCWork
- VCPreferred
- VCInternet
-where the lower level properties are properties of the property
-VCEmailAddress.
-
-Groupings are flattened out in the VObject representation such
-that:
- a.b:blah
- a.c:blahblah
-are represented as:
- b=blah
- VCGrouping=a
- c=blahblah
- VCGrouping=a
-i.e. one can read the above as:
- the property "b" has value "blah" and property "VCGrouping"
- with the value "a".
- the property "c" has value "blahblah" and property "VCGrouping"
- with the value "a".
-likewise, multi-level groupings are flatten similarly. e.g.
- a.b.c:blah
- a.b.e:blahblah
--->
- c=blah
- VCGrouping=b
- VCGrouping=a
- e=blahblah
- VCGrouping=b
- VCGrouping=a
-which read:
- the property "c" has value "blah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
- the property "e" has value "blahblah" and property "VCGrouping"
- with the value "b" which has property "VCGrouping"
- with value "a".
-
-3. Iterating Through VObject's Properties or Values
- ================================================
-The following is a skeletal form of iterating through
-all properties of a vobject, o:
-
- // assume the object of interest, o, is of type VObject
- VObjectIterator i;
- initPropIterator(&i,o);
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- // ... do something with "each" property
- }
-
-Use the API vObjectName() to access a VObject's name.
-Use the API vObjectValueType() to determine if a VObject has
- a value. For VCard/VCalendar application, you
- should not need this function as practically
- all values are either of type VCVT_USTRINGZ or
- VCVT_RAW (i.e set by setVObjectUStringZValue and
- setVObjectAnyValue APIs respectively), and the
- value returned by calls to vObjectUStringZValue
- and vObjectAnyValue are 0 if a VObject has no
- value. (There is a minor exception where VObject with
- VCDataSizeProp has value that is set by
- setVObjectLongValue).
-Use the APIs vObject???Value() to access a VObject's value.
- where ??? is the expected type.
-Use the APIs setvObject???Value() to set or modify a VObject's value.
- where ??? is the expected type.
-Use the API isAPropertyOf() to query if a name match the name of
- a property of a VObject. Since isAPropertyOf() return
- the matching property, we can use that to retrieve
- a property and subsequently the value of the property.
-
-4. Pretty Printing a VObject Tree
- ==============================
-VObject tree can be pretty printed with the printVObject() function.
-The output of pretty printing a VObject representation of the input
-test file "vobject.vcf" is shown below. Note that the indentation
-indicates the tree hirerarchy where the immediate children nodes
-of a parent node is all at the same indentation level and the
-immediate children nodes are the immediate properties of the
-associated parent nodes. In the following, {N,FN,ORG,TITLE,...}
-are immediate properties of VCARD. {F and G} are properties of N
-with value {"Alden" and "Roland"} respectively; FN has no property
-but has the value "Roland H. Alden"; EMAIL has value and
-the properties WORK, PREF, and INTERNET.
-
-
-VCARD
- N
- F="Alden"
- G="Roland"
- FN="Roland H. Alden"
- ORG
- ORGNAME="AT&T"
- OUN="Versit Project Office"
- TITLE="Consultant"
- EMAIL="sf!rincon!ralden@alden.attmail.com"
- WORK
- PREF
- INTERNET
- EMAIL="ralden@sfgate.com"
- INTERNET
- EMAIL="242-2200"
- MCIMail
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111"
- DOM
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- LABEL="Roland H. Alden
- Suite 2208
- One Pine Street
- San Francisco, CA 94111
- U.S.A."
- POSTAL
- PARCEL
- HOME
- WORK
- QP
- TEL="+1 415 296 9106"
- WORK
- PREF
- MSG
- TEL="+1 415 296 9016"
- WORK
- FAX
- TEL="+1 415 608 5981"
- MSG
- CELL
- ADR
- EXT ADD="Suite 2208"
- STREET="One Pine Street"
- L="San Francisco"
- R="CA"
- PC="94111"
- C="U.S.A."
- SOUND="ROW-LAND H ALL-DIN"
- LOGO=[raw data]
- GIF
- BASE64
- DataSize=1482
-VCALENDAR
- DCREATED="19960523T100522"
- PRODID="-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN"
- VERSION="0.3"
- VEVENT
- START="19960523T120000"
- END="19960523T130000"
- SUBTYPE="PHONE CALL"
- SUMMARY="VERSIT PDI PR Teleconference/Interview"
- DESCRIPTION="VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland"
- VEVENT
- START="19960523T113000"
- END="19960523T115500"
- SUBTYPE="LUNCH"
- SUMMARY="Eat in the cafeteria today"
-
-5. Building A VObject Representation of A VCard/VCalendar
- ======================================================
-The parser in vcc.y converts an input file with one or more
-VCard/VCalendar that is in their textual representation
-into their corresponding VObject representation.
-
-VObject representation of a VCard/VCalendar can also be built
-directly with calls to the VObject building APIs. e.g.
-
- VObject *prop;
- VObject *vcard = newVObject(VCCardProp);
- prop = addProp(vcard,VCNameProp);
- addPropValue(prop,VCFamilyNameProp,"Alden");
- addPropValue(prop,VCGivenNameProp,"Roland");
- addPropValue(vcard,VCFullNameProp,"Roland H. Alden");
- ....
-
-6. Converting A VObject Representation Into Its Textual Representation
- ===================================================================
-The VObject representation can be converted back to its textual
-representation via the call to writeVObject() or writeMemVObject()
-API. e.g.
- a. to write to a file:
- // assume vcard is of type VObject
- FILE *fp = fopen("alden.vcf","w");
- writeVObject(fp,vcard);
- a. to write to memory, and let the API allocate the required memory.
- char* clipboard = writeVObject(0,0,vcard);
- ... do something to clipboard
- free(clipboard);
- b. to write to a user allocated buffer:
- char clipboard[16384];
- int len = 16384;
- char *buf = writeVObject(clipboard,&len,vcard);
- ... buf will be equal to clipboard if the write
- is successful otherwise 0.
-
-In the case of writing to memory, the memory buffer can be either
-allocated by the API or the user. If the user allocate the
-memory for the buffer, then the length of the buffer needs to be
-communicated to the API via a variable. The variable passed as
-the length argument will be overwritten with the actual size
-of the text output. A 0 return value from writeMemVObject()
-indicates an error which could be caused by overflowing the
-size of the buffer or lack of heap memory.
-
-7. Miscellaneous Notes On VObject APIs usages
- ==========================================
-a. vcc.h -- contains basic interfaces to the parser:
- VObject* Parse_MIME(const char *input, unsigned long len);
- VObject* Parse_MIME_FromFile(FILE *file);
- -- both of this return a null-terminated list of
- VObject that is either a VCARD or VCALENDAR.
- To iterate through this list, do
- VObject *t, *v;
- v = Parse_Mime_FromFile(fp);
- while (v) {
- // ... do something to v.
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- note that call to cleanVObject will release
- resource used to represent the VObject.
-
-b. vobject.h -- contains basic interfaces to the VObject APIs.
- see the header for more details.
- The structure of VObject is purposely (hiddened) not exposed
- to the user. Every access has to be done via
- the APIs. This way, if we need to change the
- structure or implementation, the client need not
- recompile as long as the interfaces remain the
- same.
-
-c. values of a property is determined by the property definition
- itself. The vobject APIs does not attempt to enforce
- any of such definition. It is the consumer's responsibility
- to know what value is expected from a property. E.g.
- most properties have unicode string value, so to access
- the value of these type of properties, you will use
- the vObjectUStringZValue() to read the value and
- setVObjectUStringZValue() to set or modify the value.
- Refer to the VCard and VCalendar specifications for
- the definition of each property.
-
-d. properties name (id) are case insensitive.
-
-8. Brief descriptions of each APIs
- ===============================
- * the predefined properties' names (id) are listed under vobject.h
- each is of the form VC*Prop. e.g.
- #define VC7bitProp "7BIT"
- #define VCAAlarmProp "AALARM"
- ....
-
- * consumer of a VObject can only define pointers to VObject.
-
- * a variable of type VObjectIterator, say "i", can be used to iterate
- through a VObject's properties, say "o". The APIs related to
- VObjectIterator are:
- void initPropIterator(VObjectIterator *i, VObject *o);
- -- e.g. usage
- initPropIterator(&i,o);
- int moreIteration(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) { ... }
- VObject* nextVObject(VObjectIterator *i);
- -- e.g. usage
- while (moreIteration(&i)) {
- VObject *each = nextVObject(&i);
- }
-
- * VObject can be chained together to form a list. e.g. of such
- use is in the parser where the return value of the parser is
- a link list of VObject. A link list of VObject can be
- built by:
- void addList(VObject **o, VObject *p);
- and iterated by
- VObject* nextVObjectInList(VObject *o);
- -- next VObjectInList return 0 if the list
- is exhausted.
-
- * the following APIs are mainly used to construct a VObject tree:
- VObject* newVObject(const char *id);
- -- used extensively internally by VObject APIs but when
- used externally, its use is mainly limited to the
- construction of top level object (e.g. an object
- with VCCardProp or VCCalendarProp id).
-
- void deleteVObject(VObject *p);
- -- to deallocate single VObject, for most user, use
- cleanVObject(VObject *o) instead for freeing all
- resources associated with the VObject.
-
- char* dupStr(const char *s, unsigned int size);
- -- duplicate a string s. If size is 0, the string is
- assume to be a null-terminated.
-
- void deleteStr(const char *p);
- -- used to deallocate a string allocated by dupStr();
-
- void setVObjectName(VObject *o, const char* id);
- -- set the id of VObject o. This function is not
- normally used by the user. The setting of id
- is normally done as part of other APIs (e.g.
- addProp()).
-
- void setVObjectStringZValue(VObject *o, const char *s);
- -- set a string value of a VObject.
-
- void setVObjectUStringZValue(VObject *o, const wchar_t *s);
- -- set a Unicode string value of a VObject.
-
- void setVObjectIntegerValue(VObject *o, unsigned int i);
- -- set an integer value of a VObject.
-
- void setVObjectLongValue(VObject *o, unsigned long l);
- -- set an long integer value of a VObject.
-
- void setVObjectAnyValue(VObject *o, void *t);
- -- set any value of a VObject. The value type is
- unspecified.
-
- VObject* setValueWithSize(VObject *prop, void *val, unsigned int size);
- -- set a raw data (stream of bytes) value of a VObject
- whose size is size. The internal VObject representation
- is
- this object = val
- VCDataSizeProp=size
- i.e. the value val will be attached to the VObject prop
- and a property of VCDataSize whose value is size
- is also added to the object.
-
- void setVObjectVObjectValue(VObject *o, VObject *p);
- -- set a VObject as the value of another VObject.
-
- const char* vObjectName(VObject *o);
- -- retrieve the VObject's Name (i.e. id).
-
- const char* vObjectStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated string.
-
- const wchar_t* vObjectUStringZValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- null-terminated unicode string.
-
- unsigned int vObjectIntegerValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- integer.
-
- unsigned long vObjectLongValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- long integer.
-
- void* vObjectAnyValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- any value.
-
- VObject* vObjectVObjectValue(VObject *o);
- -- retrieve the VObject's value interpreted as
- a VObject.
-
- VObject* addVObjectProp(VObject *o, VObject *p);
- -- add a VObject p as a property of VObject o.
- (not normally used externally for building a
- VObject).
-
- VObject* addProp(VObject *o, const char *id);
- -- add a property whose name is id to VObject o.
-
- VObject* addPropValue(VObject *o, const char *id, const char *v);
- -- add a property whose name is id and whose value
- is a null-terminated string to VObject o.
-
- VObject* addPropSizedValue(VObject *o, const char *id,
- const char *v, unsigned int size);
- -- add a property whose name is id and whose value
- is a stream of bytes of size size, to VObject o.
-
- VObject* addGroup(VObject *o, const char *g);
- -- add a group g to VObject o.
- e.g. if g is a.b.c, you will have
- o
- c
- VCGroupingProp=b
- VCGroupingProp=a
- and the object c is returned.
-
- VObject* isAPropertyOf(VObject *o, const char *id);
- -- query if a property by the name id is in o and
- return the VObject that represent that property.
-
- void printVObject(VObject *o);
- -- pretty print VObject o to stdout (for debugging use).
-
- void writeVObject(FILE *fp, VObject *o);
- -- convert VObject o to its textual representation and
- write it to file.
-
- char* writeMemVObject(char *s, int *len, VObject *o);
- -- convert VObject o to its textual representation and
- write it to memory. If s is 0, then memory required
- to hold the textual representation will be allocated
- by this API. If a variable len is passed, len will
- be overwritten with the byte size of the textual
- representation. If s is non-zero, then s has to
- be a user allocated buffer whose size has be passed
- in len as a variable. Memory allocated by the API
- has to be freed with call to free. The return value
- of this API is either the user supplied buffer,
- the memory allocated by the API, or 0 (in case of
- failure).
-
- void cleanStrTbl();
- -- this function has to be called when all
- VObject has been destroyed.
-
- void cleanVObject(VObject *o);
- -- release all resources used by VObject o.
-
- wchar_t* fakeUnicode(const char *ps, int *bytes);
- -- convert char* to wchar_t*.
-
- extern int uStrLen(const wchar_t *u);
- -- length of unicode u.
-
- char *fakeCString(const wchar_t *u);
- -- convert wchar_t to CString (blindly assumes that
- this could be done).
-
-9. Additional Programming Notes
- ============================
-In the following notes, please refers to the listing
-of Example.vcf and its VObject Representation
-(shown at the end of this section).
-
-* Handling the Return Value of the VCard/VCalendar Parser
- The example input text file contains two root VObjects
- (a VCalendar and a VCard). The output of the VCard/VCalendar
- parser is a null-terminated list of VObjects. For this
- particular input file, the list will have two VObjects.
- The following shows a template for iterating through the
- output of the Parser:
-
- VObject *t, *v;
- v = Parse_Mime_fromFileName("example.vcf");
- while (v) {
- // currently, v will either be a VCard or a VCalendar
- // do whatever your application need to do to
- // v here ...
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
-
-* Iterating Through a VCard/VCalendar VObject
- From the VObject APIs point of view, a VCard VObject
- is the same as a VCalendar VObject. However, the application
- needs to know what are in a VCard or a VCalendar.
- For example, A VCalendar VObject can have VCDCreatedProp,
- a VCGEOLocationProp, etc, and one or more VCEventProp and
- or VCTodoProp. The VCEventProp and VCTodoProp can have
- many properties of their own, which in turn could have
- more properties (e.g. VCDAlarmProp can be a VCEventProp
- VObject's property, and VCRunTimeProp can be a
- VCDAlarmProp VObject's property. Because a VObject tree
- can be arbitrarily complex, in general, to process all
- properties and values of a VObject tree, a recursive walk
- is desirable. An example recursive VObject tree walk
- can be found in the vobject.c source lines for printVObject*
- and writeVObject* APIs. Depending on what the application need
- to do with a VCard or a VCalendar, a recursive walk
- of the VObject tree may or may not be desirable. An example
- template of a non-recursive walk is shown below:
-
- void processVCardVCalendar(char *inputFile)
- {
- VObject *t, *v;
- v = Parse_Mime_fromFileName(inputFile);
- while (v) {
- char *n = vObjectName(v);
- if (strcmp(n,VCCardProp) == 0) {
- do_VCard(v);
- }
- else if (strcmp(n,VCCalendarProp) == 0) {
- do_VCalendar(v);
- }
- else {
- // don't know how to handle anything else!
- }
- t = v;
- v = nextVObjectInList(v);
- cleanVObject(t);
- }
- }
-
- void do_VCard(VObject *vcard)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primary purpose of this example is to
- // show how to iterate through a VCard VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCNameProp)==0) {
- do_name(eachProp);
- }
- else if (strcmp(n,VCEmailProp)==0) {
- do_email(eachProp);
- }
- else if (strcmp(n,VCLabelProp)==0) {
- do_label(eachProp);
- }
- else if ....
- }
- }
-
- void do_VCalendar(VObject *vcal)
- {
- VObjectIterator t;
- initPropIterator(&t,vcard);
- while (moreIteration(&t)) {
- VObject *eachProp = nextVObject(&t);
- // The primary purpose of this example is to
- // show how to iterate through a VCalendar VObject,
- // it is not meant to be efficient at all.
- char *n = vObjectName(eachProp);
- if (strcmp(n,VCDCreatedProp)==0) {
- do_DCreated(eachProp);
- }
- else if (strcmp(n,VCVersionProp)==0) {
- do_Version(eachProp);
- }
- else if (strcmp(n,VCTodoProp)==0) {
- do_Todo(eachProp);
- }
- else if (strcmp(n,VCEventProp)==0) {
- do_Event(eachProp);
- }
- else if ....
- }
- }
-
- void do_Todo(VObject *vtodo) { ... }
-
- void do_Event(VObject *vevent) { ... }
-
- ...
-
-* Property's Values and Properties
- The VObject APIs do not attempt to check for the
- correctness of the values of a property. Nor do they
- will prevent the user from attaching a non-VCard/VCalendar
- standard property to a VCard/VCalendar property. Take
- the example of line [11] of the example, "O.K" is not
- a valid value of VCStatusProp. It is up to the application
- to accept or reject the value of a property.
-
-* Output of printVObject
- PrintVObject pretty prints a VObject tree in human
- readable form. See the listing at the end of the file
- for an example output of printVObject on the example
- input file "Example.vcf".
-
- Note that binary data are not shown in the output of
- printVObject. Instead, a note is made ([raw data]) to
- indicate that there exists such a binary data.
-
-* Note on Binary Data
- When the value of a property is a binary data, it is only
- useful to know the size of the binary data.
-
- In the case of the VCard/VCalendar parser, it chooses
- to represent the size information as a separate property
- called VCDataSizeProp whose value is the size of the binary
- data. The APIs sequence to construct the VObject subtree
- of line [44] of Example.vcf is
-
- // VObject *vcard;
- VObject *p1 = addProp(vcard,VCLogoProp);
- (void) addProp(p1,VCGIFProp);
- (void) addProp(p1,VCBASE64Prop);
- VObject *p2 = addProp(p1,VCDataSizeProp);
- (void) setVObjectLongValue(p2,1482);
- setVObjectAnyValue(vcard,...pointer to binary data);
-
- Note the presence of VCBase64Prop will cause the
- writeVObject API to output the binary data as BASE64 text.
- For VCard/VCalendar application, having the VCBase64Prop
- property is practically always necessary for property with
- binary data as its value.
-
-* Note on Quoted-Printable String
- String value with embedded newline are written out as
- quoted-prinatable string. It is therefore important
- to mark a property with a string value that has
- one or more embedded newlines, with the VCQutedPrintableProp
- property. e.g.
-
- // VObject *root;
- char *msg="To be\nor\nnot to be";
- VObject *p = addPropValue(root,VCDescriptionProp,msg);
- // the following is how you mark a property with
- // a property. In this case, the marker is
- // VCQuotedPrintableProp
- addProp(p,VCQuotedPrintableProp);
-
-* Note on Unicode
- Although, the current parser takes ASCII text file only,
- string values are all stored as Unicode in the VObject tree.
- For now, when using the VObject APIs to construct a
- VObject tree, one should always convert ASCII string value
- to a Unicode string value:
-
- // VObject *root;
- VObject *p = addProp(root,VCSomeProp);
- setVObjectUStringZValue(p,fakeUnicode(someASCIIStringZvalue));
-
- An API is provided to simplify the above process:
-
- addPropValue(root,VCSomeProp,someASCIIStringZValue);
-
- Note that someASCIISTringZValue is automatically converted to
- Unicode by addPropValue API, where as, the former code
- sequence do an explicit call to fakeUnicode.
-
- To read back the value, one should use the vObjectUStringZValue
- API not vObjectStringZValue API. The value returned by the
- vObjectUStringZValue API is a Unicode string. If the application
- do not know how to handle Unicode string, it can use the
- fakeCString API to convert it back to ASCII string (as long
- as the conversion is meaningful).
-
- Note that fakeCString return a heap allocated memory. It is
- important to call deleteStr on fakeCString return value if
- it is not longer required (or there will be memory leak).
-
- NOTE: Unfortunately, at the point when this document is written,
- there is still no consensus on how Unicode is to be handled
- in the textual representation of VCard/VCalendar. So, there
- is no version of writeVObject and the parser to output and
- input Unicode textual representation of VCard/VCalendar.
-
-
-Example.vcf
------------
-line
-number Input Text (example.vcf)
------- ----------
-1 BEGIN:VCALENDAR
-2 DCREATED:19961102T100522
-3 GEO:0,0
-4 VERSION:1.0
-5 BEGIN:VEVENT
-6 DTSTART:19961103T000000
-7 DTEND:20000101T000000
-8 DESCRIPTION;QUOTED-PRINTABLE:To be =0A=
-9 or =0A=
-10 not to be
-11 STATUS:O.K.
-12 X-ACTION:No action required
-13 DALARM:19961103T114500;5;3;Enjoy
-14 MALARM:19970101T120000;;;johny@nowhere.com;Call Mom.
-15 END:VEVENT
-16
-17 BEGIN:VTODO
-18 DUE:19960614T0173000
-19 DESCRIPTION:Relex.
-20 END:VTODO
-21
-22 END:VCALENDAR
-23
-24 BEGIN:VCARD
-25 N:Alden;Roland
-26 FN:Roland H. Alden
-27 ORG:AT&T;Versit Project Office
-28 TITLE:Consultant
-29 EMAIL;WORK;PREF;INTERNET:ralden@ralden.com
-30 LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-31 Suite 2208=0A=
-32 One Pine Street=0A=
-33 San Francisco, CA 94111
-34 LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A=
-35 Suite 2208=0A=
-36 One Pine Street=0A=
-37 San Francisco, CA 94111=0A=
-38 U.S.A.
-39 TEL;WORK;PREF;MSG:+1 415 296 9106
-40 TEL;WORK;FAX:+1 415 296 9016
-41 TEL;MSG;CELL:+1 415 608 5981
-42 ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A.
-43 SOUND:ROW-LAND H ALL-DIN
-44 LOGO;GIF;BASE64:
-45 R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC
- ... 30 lines of BASE64 data not shown here.
-76 END:VCARD
-
-
-VObject Representation of Example.vcf:
--------------------------------------
-line
-in
-text
-file VObject Tree as Printed by printVObject API
----- -------------------------------------------
-1 VCALENDAR
-2 DCREATED="19961102T100522"
-3 GEO="0,0"
-4 VERSION="1.0"
-5 VEVENT
-6 DTSTART="19961103T000000"
-7 DTEND="20000101T000000"
-8 DESCRIPTION="To be
-9 or
-10 not to be"
-8 QUOTED-PRINTABLE
-11 STATUS="O.K."
-12 X-ACTION="No action required"
-13 DALARM
-13 RUNTIME="19961103T114500"
-13 SNOOZETIME="5"
-13 REPEATCOUNT="3"
-13 DISPLAYSTRING="Enjoy"
-14 MALARM
-14 RUNTIME="19970101T120000"
-14 EMAIL="johny@nowhere.com"
-14 NOTE="Call Mom"
-17 VTODO
-18 DUE="19960614T0173000"
-19 DESCRIPTION="Relex."
-24 VCARD
-25 N
-25 F="Alden"
-25 G="Roland"
-26 FN="Roland H. Alden"
-27 ORG
-27 ORGNAME="AT&T"
-27 OUN="Versit Project Office"
-28 TITLE="Consultant"
-29 EMAIL="ralden@alden.com"
-29 WORK
-29 PREF
-29 INTERNET
-30 LABEL="Roland H. Alden
-31 Suite 2208
-32 One Pine Street
-33 San Francisco, CA 94111"
-30 DOM
-30 POSTAL
-30 PARCEL
-30 HOME
-30 WORK
-30 QUOTED-PRINTABLE
-34 LABEL="Roland H. Alden
-35 Suite 2208
-36 One Pine Street
-37 San Francisco, CA 94111
-38 U.S.A."
-34 POSTAL
-34 PARCEL
-34 HOME
-34 WORK
-34 QUOTED-PRINTABLE
-39 TEL="+1 415 296 9106"
-39 WORK
-39 PREF
-39 MSG
-40 TEL="+1 415 296 9016"
-40 WORK
-40 FAX
-41 TEL="+1 415 608 5981"
-41 MSG
-41 CELL
-42 ADR
-42 EXT ADD="Suite 2208"
-42 STREET="One Pine Street"
-42 L="San Francisco"
-42 R="CA"
-42 PC="94111"
-42 C="U.S.A."
-43 SOUND="ROW-LAND H ALL-DIN"
-44 LOGO=[raw data]
-44 GIF
-44 BASE64
-44 DATASIZE=1482
-
+SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International +Business Machines Corporation and Siemens Rolm Communications Inc. + +SPDX-License-Identifier: LicenseRef-APPLEMIT + +The software is provided with RESTRICTED RIGHTS. Use, duplication, or +disclosure by the government are subject to restrictions set forth in +DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. + +NOTE: If you used the earlier APIs released by Versit +then you will want to look at the document "migrate.doc" +included with this package. It contains a discussion of +the differences between the old API and this one. + +---------------------------------------------------------------- + +The vCard/vCalendar C interface is implemented in the set +of files as follows: + +vcc.y, yacc source, and vcc.c, the yacc output you will use +implements the core parser + +vobject.c implements an API that insulates the caller from +the parser and changes in the vCard/vCalendar BNF + +port.h defines compilation environment dependent stuff + +vcc.h and vobject.h are header files for their .c counterparts + +vcaltmp.h and vcaltmp.c implement vCalendar "macro" functions +which you may find useful. + +test.c is a standalone test driver that exercises some of +the features of the APIs provided. Invoke test.exe on a +VCARD/VCALENDAR input text file and you will see the pretty +print output of the internal representation (this pretty print +output should give you a good idea of how the internal +representation looks like -- there is one such output in the +following too). Also, a file with the .out suffix is generated +to show that the internal representation can be written back +in the original text format. + +----------------------------------------------------------------- + + + VObject for VCard/VCalendar + +Table of Contents +================= +1. VObject +2. Internal Representations of VCard/VCalendar +3. Iterating Through VObject's Properties or Values +4. Pretty Printing a VObject Tree +5. Building A VObject Representation of A VCard/VCalendar +6. Converting A VObject Representation Into Its Textual Representation +7. Miscellaneous Notes On VObject APIs usages +8. Brief descriptions of each APIs +9. Additional Programming Notes. + +This document is mainly about the VObject and its APIs. The main +use of a VObject is to represent a VCard or a VCalendar inside +a program. However, its use is not limited to aforemention as it +can represent an arbitrary information that makes up of a tree or +forest of properties/values. + +1. VObject + ======= +A VObject can have a name (id) and a list of associated properties and +a value. Each property is itself a VObject. + +2. Internal Representations of VCard/VCalendar + =========================================== +A list of VCard or a VCalendar is represented by a list of VObjects. +The name (id) of the VObjects in the list is either VCCardProp or +VCCalProp. Each of these VObjects can have a list of properties. +Since a property is represented as a VObject, each of these properties +can have a name, a list of properties, and a value. + +For example, the input file "vobject.vcf": + +BEGIN:VCARD +N:Alden;Roland +FN:Roland H. Alden +ORG:AT&T;Versit Project Office +TITLE:Consultant +EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com +EMAIL;INTERNET:ralden@sfgate.com +EMAIL;MCIMail:242-2200 +LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A= +Suite 2208=0A= +One Pine Street=0A= +San Francisco, CA 94111 +LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A= +Suite 2208=0A= +One Pine Street=0A= +San Francisco, CA 94111=0A= +U.S.A. +TEL;WORK;PREF;MSG:+1 415 296 9106 +TEL;WORK;FAX:+1 415 296 9016 +TEL;MSG;CELL:+1 415 608 5981 +ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A. +SOUND:ROW-LAND H ALL-DIN +LOGO;GIF;BASE64: + R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC + QjExMSEhIRAQEO///87v9973/73n95zW71K13jGl1nvG50Kt3iGc1gCMzq3e94zO + 7xCU1nO952O15wAAACwAAAAApgBOAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zv + /8CgcEj8QTaeywWTyWCUno2kSK0KI5tLc8vtNi+WiHVMlj0mFK96nalsxOW4fPSw + cNj4tQc+7xcjGh4WExJTJYUTFkp3eU0eEH6RkpOUlTARhRoWm5ydFpCWoS0QEqAu + ARKaHRcVjV0borEoFl0cSre4Sq67FA+yvwAeTU8XHZ7HmxS6u2wVfMCVpAE3pJoW + ylrMptDcOqSF4OHg3eQ5pInInb7lcc86mNbLzBXsZbRfUOn6ucyNHvVWJHCpQFDf + MWwEEzLqx2YCQCqF3OnItClJNmYcJD7cSAKTuI/gtnEcOQKkyVIk6/+ds5CkFcMM + 61LiENikwi1jBnNyuvUSjwWZOS5uIZarqNFcNl32XMMB6I06GgoJ+bZp1ZKeDl8E + +MC1K1cBIhZ4HUu2LAsCZdOWRQDt20lxIlccSHsgrNq7Xc/ixcsWmNu34WKyYJCW + gQjCe9XqTZy2L4pv04gg2sSKSc8OLgTcBSuWsdkVaD2TdXyiQxebFyjo1Gnx6tJm + LuaqrdtZtNfFtruSNmF5IKujwIsmJbjwtRqNJhrcNVw79wcRAgogmE4ArIjQzj/s + JvHAGCFDQR4UqigPK4sBe62XwO51OwADiMcqUG+iOdcFAL+hW20BfAoEexlwAnu6 + mZDAXQ1EVh//WfhxJB5gIbHgwFgOTOiVAgOuVQKAfKFg3weGwSBYFZMp4hpDGKyA + 3lgJKECWgiMQyBVpW+0V4oJjNfhCNkR1IgWEb21QlRK9GdfFCgeOZYBsXgm4noYj + GEBhAQHYh0J8XenoQnFGdrkUciJY6FUAK15ogozakcBhliKsyZWHDMZQ0wWC/Aim + DB6h01KRr/lXQgFxAqDcWDACgCZpUnrVQJtjwTnWjS6MWAYqqfDnSaEkJOlVXQBo + 2pWTMUJ53WgAuPncCR9q6VQMAYjZlXWJmknCoSUM2p4BC+SaKwG88hoZlvfFMM4f + hQh5TXkv+RklWYtC91mopJIAKFkJlDAW/wF25ShnLbeo5gmQ+1FGkJdrKCuCi2OR + BuwHBcwqKgABrMtVAgpem61XkLbAJ7n8uiIpvGVhO4KpH1QLbbpqLheZvQCkGoNL + thSzSTg2UGVBBzbtaxwKsYrmgLvRAlCmWgwMAADD66rKAgR3XlGspcdkZYK8ibU7 + asgEl+XAyB8I7PCqMWiWncGGimpfAgO4ypXSPpOVLwsRCDJxRD2AoyeRRv5kApO5 + fXwzwvfOKLKtaTWtbQxccmGLTZy8xYlVSvXbhbk0M2YzrYfJJ0K8m+V9NgxpyC04 + UycI/aiuiH9Y8NftDUwWp1Wm5UABnAUKwwRsPFGBt4Oc9PZvGvNLwf8JOZt8Arpe + eY23yDovwIDiBX74NAsPVLDJj3Hh4JEExsKcjrlKf9DsCVx3ZfLqAKBuG1s/A90C + z2KjYHjjyPOdG1spz6BBUr+BcUxUb1nDCTa/VZD2Uv+YkLPAKJC9dNEh7628WgqI + ybzlaA+ufxMa6bxC6ciLUQLcx5UGIAAsAkDA6wQkOxrcY39yo4cQMNWCAPTKV1R4 + wPkgaBxzOc8FtMiF1NoGoXBRJjgoPApmPsjCFlbMdzCM4TFy50IXxI2DPcHAv2rY + gghsEIeu8CAPW6ABIPYEFkOsAeaMyIz0JfGJUExBBGRIRX0IMYovWCIT1eBELNpA + i1vcgta8iANPCIQOghzQABl30J0tXqBla4wjFLFQxZzAUY42CIAd5OYBCuKxB2c4 + I0b28EcrQKADgmSKB9RYyDhA4BqCxIBqrtjIMTwoFeCjYSU3KZMQAAA7 + +BEGIN:VCALENDAR +DCREATED:19960523T100522 +PRODID:-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN +VERSION:0.3 +BEGIN:VEVENT +START:19960523T120000 +END:19960523T130000 +SUBTYPE:PHONE CALL +SUMMARY:VERSIT PDI PR Teleconference/Interview +DESCRIPTION:VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland +END:VEVENT +BEGIN:VEVENT +START:19960523T113000 +END:19960523T115500 +SUBTYPE:LUNCH +SUMMARY:Eat in the cafeteria today +END:VEVENT +END:VCALENDAR + +END:VCARD + + +will conceptually be represented as + vcard + VCNameProp + VCFamilyNameProp=Alden + VCGivenNameProp=Roland + VCFullNameProp=Roland H.Alden + .... + +note that + EMAIL;WORK;PREF;INTERNET:sf!rincon!ralden@alden.attmail.com +will be represented as: + VCEmailAddress=sf!rincon!ralden@alden.attmail.com + VCWork + VCPreferred + VCInternet +where the lower level properties are properties of the property +VCEmailAddress. + +Groupings are flattened out in the VObject representation such +that: + a.b:blah + a.c:blahblah +are represented as: + b=blah + VCGrouping=a + c=blahblah + VCGrouping=a +i.e. one can read the above as: + the property "b" has value "blah" and property "VCGrouping" + with the value "a". + the property "c" has value "blahblah" and property "VCGrouping" + with the value "a". +likewise, multi-level groupings are flatten similarly. e.g. + a.b.c:blah + a.b.e:blahblah +--> + c=blah + VCGrouping=b + VCGrouping=a + e=blahblah + VCGrouping=b + VCGrouping=a +which read: + the property "c" has value "blah" and property "VCGrouping" + with the value "b" which has property "VCGrouping" + with value "a". + the property "e" has value "blahblah" and property "VCGrouping" + with the value "b" which has property "VCGrouping" + with value "a". + +3. Iterating Through VObject's Properties or Values + ================================================ +The following is a skeletal form of iterating through +all properties of a vobject, o: + + // assume the object of interest, o, is of type VObject + VObjectIterator i; + initPropIterator(&i,o); + while (moreIteration(&i)) { + VObject *each = nextVObject(&i); + // ... do something with "each" property + } + +Use the API vObjectName() to access a VObject's name. +Use the API vObjectValueType() to determine if a VObject has + a value. For VCard/VCalendar application, you + should not need this function as practically + all values are either of type VCVT_USTRINGZ or + VCVT_RAW (i.e set by setVObjectUStringZValue and + setVObjectAnyValue APIs respectively), and the + value returned by calls to vObjectUStringZValue + and vObjectAnyValue are 0 if a VObject has no + value. (There is a minor exception where VObject with + VCDataSizeProp has value that is set by + setVObjectLongValue). +Use the APIs vObject???Value() to access a VObject's value. + where ??? is the expected type. +Use the APIs setvObject???Value() to set or modify a VObject's value. + where ??? is the expected type. +Use the API isAPropertyOf() to query if a name match the name of + a property of a VObject. Since isAPropertyOf() return + the matching property, we can use that to retrieve + a property and subsequently the value of the property. + +4. Pretty Printing a VObject Tree + ============================== +VObject tree can be pretty printed with the printVObject() function. +The output of pretty printing a VObject representation of the input +test file "vobject.vcf" is shown below. Note that the indentation +indicates the tree hirerarchy where the immediate children nodes +of a parent node is all at the same indentation level and the +immediate children nodes are the immediate properties of the +associated parent nodes. In the following, {N,FN,ORG,TITLE,...} +are immediate properties of VCARD. {F and G} are properties of N +with value {"Alden" and "Roland"} respectively; FN has no property +but has the value "Roland H. Alden"; EMAIL has value and +the properties WORK, PREF, and INTERNET. + + +VCARD + N + F="Alden" + G="Roland" + FN="Roland H. Alden" + ORG + ORGNAME="AT&T" + OUN="Versit Project Office" + TITLE="Consultant" + EMAIL="sf!rincon!ralden@alden.attmail.com" + WORK + PREF + INTERNET + EMAIL="ralden@sfgate.com" + INTERNET + EMAIL="242-2200" + MCIMail + LABEL="Roland H. Alden + Suite 2208 + One Pine Street + San Francisco, CA 94111" + DOM + POSTAL + PARCEL + HOME + WORK + QP + LABEL="Roland H. Alden + Suite 2208 + One Pine Street + San Francisco, CA 94111 + U.S.A." + POSTAL + PARCEL + HOME + WORK + QP + TEL="+1 415 296 9106" + WORK + PREF + MSG + TEL="+1 415 296 9016" + WORK + FAX + TEL="+1 415 608 5981" + MSG + CELL + ADR + EXT ADD="Suite 2208" + STREET="One Pine Street" + L="San Francisco" + R="CA" + PC="94111" + C="U.S.A." + SOUND="ROW-LAND H ALL-DIN" + LOGO=[raw data] + GIF + BASE64 + DataSize=1482 +VCALENDAR + DCREATED="19960523T100522" + PRODID="-//Alden Roland/Hand Crafted In North Carolina//NONSGML Made By Hand//EN" + VERSION="0.3" + VEVENT + START="19960523T120000" + END="19960523T130000" + SUBTYPE="PHONE CALL" + SUMMARY="VERSIT PDI PR Teleconference/Interview" + DESCRIPTION="VERSIT PDI PR Teleconference/Interview With Tom Streeter and Alden Roland" + VEVENT + START="19960523T113000" + END="19960523T115500" + SUBTYPE="LUNCH" + SUMMARY="Eat in the cafeteria today" + +5. Building A VObject Representation of A VCard/VCalendar + ====================================================== +The parser in vcc.y converts an input file with one or more +VCard/VCalendar that is in their textual representation +into their corresponding VObject representation. + +VObject representation of a VCard/VCalendar can also be built +directly with calls to the VObject building APIs. e.g. + + VObject *prop; + VObject *vcard = newVObject(VCCardProp); + prop = addProp(vcard,VCNameProp); + addPropValue(prop,VCFamilyNameProp,"Alden"); + addPropValue(prop,VCGivenNameProp,"Roland"); + addPropValue(vcard,VCFullNameProp,"Roland H. Alden"); + .... + +6. Converting A VObject Representation Into Its Textual Representation + =================================================================== +The VObject representation can be converted back to its textual +representation via the call to writeVObject() or writeMemVObject() +API. e.g. + a. to write to a file: + // assume vcard is of type VObject + FILE *fp = fopen("alden.vcf","w"); + writeVObject(fp,vcard); + a. to write to memory, and let the API allocate the required memory. + char* clipboard = writeVObject(0,0,vcard); + ... do something to clipboard + free(clipboard); + b. to write to a user allocated buffer: + char clipboard[16384]; + int len = 16384; + char *buf = writeVObject(clipboard,&len,vcard); + ... buf will be equal to clipboard if the write + is successful otherwise 0. + +In the case of writing to memory, the memory buffer can be either +allocated by the API or the user. If the user allocate the +memory for the buffer, then the length of the buffer needs to be +communicated to the API via a variable. The variable passed as +the length argument will be overwritten with the actual size +of the text output. A 0 return value from writeMemVObject() +indicates an error which could be caused by overflowing the +size of the buffer or lack of heap memory. + +7. Miscellaneous Notes On VObject APIs usages + ========================================== +a. vcc.h -- contains basic interfaces to the parser: + VObject* Parse_MIME(const char *input, unsigned long len); + VObject* Parse_MIME_FromFile(FILE *file); + -- both of this return a null-terminated list of + VObject that is either a VCARD or VCALENDAR. + To iterate through this list, do + VObject *t, *v; + v = Parse_Mime_FromFile(fp); + while (v) { + // ... do something to v. + t = v; + v = nextVObjectInList(v); + cleanVObject(t); + } + note that call to cleanVObject will release + resource used to represent the VObject. + +b. vobject.h -- contains basic interfaces to the VObject APIs. + see the header for more details. + The structure of VObject is purposely (hiddened) not exposed + to the user. Every access has to be done via + the APIs. This way, if we need to change the + structure or implementation, the client need not + recompile as long as the interfaces remain the + same. + +c. values of a property is determined by the property definition + itself. The vobject APIs does not attempt to enforce + any of such definition. It is the consumer's responsibility + to know what value is expected from a property. E.g. + most properties have unicode string value, so to access + the value of these type of properties, you will use + the vObjectUStringZValue() to read the value and + setVObjectUStringZValue() to set or modify the value. + Refer to the VCard and VCalendar specifications for + the definition of each property. + +d. properties name (id) are case insensitive. + +8. Brief descriptions of each APIs + =============================== + * the predefined properties' names (id) are listed under vobject.h + each is of the form VC*Prop. e.g. + #define VC7bitProp "7BIT" + #define VCAAlarmProp "AALARM" + .... + + * consumer of a VObject can only define pointers to VObject. + + * a variable of type VObjectIterator, say "i", can be used to iterate + through a VObject's properties, say "o". The APIs related to + VObjectIterator are: + void initPropIterator(VObjectIterator *i, VObject *o); + -- e.g. usage + initPropIterator(&i,o); + int moreIteration(VObjectIterator *i); + -- e.g. usage + while (moreIteration(&i)) { ... } + VObject* nextVObject(VObjectIterator *i); + -- e.g. usage + while (moreIteration(&i)) { + VObject *each = nextVObject(&i); + } + + * VObject can be chained together to form a list. e.g. of such + use is in the parser where the return value of the parser is + a link list of VObject. A link list of VObject can be + built by: + void addList(VObject **o, VObject *p); + and iterated by + VObject* nextVObjectInList(VObject *o); + -- next VObjectInList return 0 if the list + is exhausted. + + * the following APIs are mainly used to construct a VObject tree: + VObject* newVObject(const char *id); + -- used extensively internally by VObject APIs but when + used externally, its use is mainly limited to the + construction of top level object (e.g. an object + with VCCardProp or VCCalendarProp id). + + void deleteVObject(VObject *p); + -- to deallocate single VObject, for most user, use + cleanVObject(VObject *o) instead for freeing all + resources associated with the VObject. + + char* dupStr(const char *s, unsigned int size); + -- duplicate a string s. If size is 0, the string is + assume to be a null-terminated. + + void deleteStr(const char *p); + -- used to deallocate a string allocated by dupStr(); + + void setVObjectName(VObject *o, const char* id); + -- set the id of VObject o. This function is not + normally used by the user. The setting of id + is normally done as part of other APIs (e.g. + addProp()). + + void setVObjectStringZValue(VObject *o, const char *s); + -- set a string value of a VObject. + + void setVObjectUStringZValue(VObject *o, const wchar_t *s); + -- set a Unicode string value of a VObject. + + void setVObjectIntegerValue(VObject *o, unsigned int i); + -- set an integer value of a VObject. + + void setVObjectLongValue(VObject *o, unsigned long l); + -- set an long integer value of a VObject. + + void setVObjectAnyValue(VObject *o, void *t); + -- set any value of a VObject. The value type is + unspecified. + + VObject* setValueWithSize(VObject *prop, void *val, unsigned int size); + -- set a raw data (stream of bytes) value of a VObject + whose size is size. The internal VObject representation + is + this object = val + VCDataSizeProp=size + i.e. the value val will be attached to the VObject prop + and a property of VCDataSize whose value is size + is also added to the object. + + void setVObjectVObjectValue(VObject *o, VObject *p); + -- set a VObject as the value of another VObject. + + const char* vObjectName(VObject *o); + -- retrieve the VObject's Name (i.e. id). + + const char* vObjectStringZValue(VObject *o); + -- retrieve the VObject's value interpreted as + null-terminated string. + + const wchar_t* vObjectUStringZValue(VObject *o); + -- retrieve the VObject's value interpreted as + null-terminated unicode string. + + unsigned int vObjectIntegerValue(VObject *o); + -- retrieve the VObject's value interpreted as + integer. + + unsigned long vObjectLongValue(VObject *o); + -- retrieve the VObject's value interpreted as + long integer. + + void* vObjectAnyValue(VObject *o); + -- retrieve the VObject's value interpreted as + any value. + + VObject* vObjectVObjectValue(VObject *o); + -- retrieve the VObject's value interpreted as + a VObject. + + VObject* addVObjectProp(VObject *o, VObject *p); + -- add a VObject p as a property of VObject o. + (not normally used externally for building a + VObject). + + VObject* addProp(VObject *o, const char *id); + -- add a property whose name is id to VObject o. + + VObject* addPropValue(VObject *o, const char *id, const char *v); + -- add a property whose name is id and whose value + is a null-terminated string to VObject o. + + VObject* addPropSizedValue(VObject *o, const char *id, + const char *v, unsigned int size); + -- add a property whose name is id and whose value + is a stream of bytes of size size, to VObject o. + + VObject* addGroup(VObject *o, const char *g); + -- add a group g to VObject o. + e.g. if g is a.b.c, you will have + o + c + VCGroupingProp=b + VCGroupingProp=a + and the object c is returned. + + VObject* isAPropertyOf(VObject *o, const char *id); + -- query if a property by the name id is in o and + return the VObject that represent that property. + + void printVObject(VObject *o); + -- pretty print VObject o to stdout (for debugging use). + + void writeVObject(FILE *fp, VObject *o); + -- convert VObject o to its textual representation and + write it to file. + + char* writeMemVObject(char *s, int *len, VObject *o); + -- convert VObject o to its textual representation and + write it to memory. If s is 0, then memory required + to hold the textual representation will be allocated + by this API. If a variable len is passed, len will + be overwritten with the byte size of the textual + representation. If s is non-zero, then s has to + be a user allocated buffer whose size has be passed + in len as a variable. Memory allocated by the API + has to be freed with call to free. The return value + of this API is either the user supplied buffer, + the memory allocated by the API, or 0 (in case of + failure). + + void cleanStrTbl(); + -- this function has to be called when all + VObject has been destroyed. + + void cleanVObject(VObject *o); + -- release all resources used by VObject o. + + wchar_t* fakeUnicode(const char *ps, int *bytes); + -- convert char* to wchar_t*. + + extern int uStrLen(const wchar_t *u); + -- length of unicode u. + + char *fakeCString(const wchar_t *u); + -- convert wchar_t to CString (blindly assumes that + this could be done). + +9. Additional Programming Notes + ============================ +In the following notes, please refers to the listing +of Example.vcf and its VObject Representation +(shown at the end of this section). + +* Handling the Return Value of the VCard/VCalendar Parser + The example input text file contains two root VObjects + (a VCalendar and a VCard). The output of the VCard/VCalendar + parser is a null-terminated list of VObjects. For this + particular input file, the list will have two VObjects. + The following shows a template for iterating through the + output of the Parser: + + VObject *t, *v; + v = Parse_Mime_fromFileName("example.vcf"); + while (v) { + // currently, v will either be a VCard or a VCalendar + // do whatever your application need to do to + // v here ... + t = v; + v = nextVObjectInList(v); + cleanVObject(t); + } + +* Iterating Through a VCard/VCalendar VObject + From the VObject APIs point of view, a VCard VObject + is the same as a VCalendar VObject. However, the application + needs to know what are in a VCard or a VCalendar. + For example, A VCalendar VObject can have VCDCreatedProp, + a VCGEOLocationProp, etc, and one or more VCEventProp and + or VCTodoProp. The VCEventProp and VCTodoProp can have + many properties of their own, which in turn could have + more properties (e.g. VCDAlarmProp can be a VCEventProp + VObject's property, and VCRunTimeProp can be a + VCDAlarmProp VObject's property. Because a VObject tree + can be arbitrarily complex, in general, to process all + properties and values of a VObject tree, a recursive walk + is desirable. An example recursive VObject tree walk + can be found in the vobject.c source lines for printVObject* + and writeVObject* APIs. Depending on what the application need + to do with a VCard or a VCalendar, a recursive walk + of the VObject tree may or may not be desirable. An example + template of a non-recursive walk is shown below: + + void processVCardVCalendar(char *inputFile) + { + VObject *t, *v; + v = Parse_Mime_fromFileName(inputFile); + while (v) { + char *n = vObjectName(v); + if (strcmp(n,VCCardProp) == 0) { + do_VCard(v); + } + else if (strcmp(n,VCCalendarProp) == 0) { + do_VCalendar(v); + } + else { + // don't know how to handle anything else! + } + t = v; + v = nextVObjectInList(v); + cleanVObject(t); + } + } + + void do_VCard(VObject *vcard) + { + VObjectIterator t; + initPropIterator(&t,vcard); + while (moreIteration(&t)) { + VObject *eachProp = nextVObject(&t); + // The primary purpose of this example is to + // show how to iterate through a VCard VObject, + // it is not meant to be efficient at all. + char *n = vObjectName(eachProp); + if (strcmp(n,VCNameProp)==0) { + do_name(eachProp); + } + else if (strcmp(n,VCEmailProp)==0) { + do_email(eachProp); + } + else if (strcmp(n,VCLabelProp)==0) { + do_label(eachProp); + } + else if .... + } + } + + void do_VCalendar(VObject *vcal) + { + VObjectIterator t; + initPropIterator(&t,vcard); + while (moreIteration(&t)) { + VObject *eachProp = nextVObject(&t); + // The primary purpose of this example is to + // show how to iterate through a VCalendar VObject, + // it is not meant to be efficient at all. + char *n = vObjectName(eachProp); + if (strcmp(n,VCDCreatedProp)==0) { + do_DCreated(eachProp); + } + else if (strcmp(n,VCVersionProp)==0) { + do_Version(eachProp); + } + else if (strcmp(n,VCTodoProp)==0) { + do_Todo(eachProp); + } + else if (strcmp(n,VCEventProp)==0) { + do_Event(eachProp); + } + else if .... + } + } + + void do_Todo(VObject *vtodo) { ... } + + void do_Event(VObject *vevent) { ... } + + ... + +* Property's Values and Properties + The VObject APIs do not attempt to check for the + correctness of the values of a property. Nor do they + will prevent the user from attaching a non-VCard/VCalendar + standard property to a VCard/VCalendar property. Take + the example of line [11] of the example, "O.K" is not + a valid value of VCStatusProp. It is up to the application + to accept or reject the value of a property. + +* Output of printVObject + PrintVObject pretty prints a VObject tree in human + readable form. See the listing at the end of the file + for an example output of printVObject on the example + input file "Example.vcf". + + Note that binary data are not shown in the output of + printVObject. Instead, a note is made ([raw data]) to + indicate that there exists such a binary data. + +* Note on Binary Data + When the value of a property is a binary data, it is only + useful to know the size of the binary data. + + In the case of the VCard/VCalendar parser, it chooses + to represent the size information as a separate property + called VCDataSizeProp whose value is the size of the binary + data. The APIs sequence to construct the VObject subtree + of line [44] of Example.vcf is + + // VObject *vcard; + VObject *p1 = addProp(vcard,VCLogoProp); + (void) addProp(p1,VCGIFProp); + (void) addProp(p1,VCBASE64Prop); + VObject *p2 = addProp(p1,VCDataSizeProp); + (void) setVObjectLongValue(p2,1482); + setVObjectAnyValue(vcard,...pointer to binary data); + + Note the presence of VCBase64Prop will cause the + writeVObject API to output the binary data as BASE64 text. + For VCard/VCalendar application, having the VCBase64Prop + property is practically always necessary for property with + binary data as its value. + +* Note on Quoted-Printable String + String value with embedded newline are written out as + quoted-prinatable string. It is therefore important + to mark a property with a string value that has + one or more embedded newlines, with the VCQutedPrintableProp + property. e.g. + + // VObject *root; + char *msg="To be\nor\nnot to be"; + VObject *p = addPropValue(root,VCDescriptionProp,msg); + // the following is how you mark a property with + // a property. In this case, the marker is + // VCQuotedPrintableProp + addProp(p,VCQuotedPrintableProp); + +* Note on Unicode + Although, the current parser takes ASCII text file only, + string values are all stored as Unicode in the VObject tree. + For now, when using the VObject APIs to construct a + VObject tree, one should always convert ASCII string value + to a Unicode string value: + + // VObject *root; + VObject *p = addProp(root,VCSomeProp); + setVObjectUStringZValue(p,fakeUnicode(someASCIIStringZvalue)); + + An API is provided to simplify the above process: + + addPropValue(root,VCSomeProp,someASCIIStringZValue); + + Note that someASCIISTringZValue is automatically converted to + Unicode by addPropValue API, where as, the former code + sequence do an explicit call to fakeUnicode. + + To read back the value, one should use the vObjectUStringZValue + API not vObjectStringZValue API. The value returned by the + vObjectUStringZValue API is a Unicode string. If the application + do not know how to handle Unicode string, it can use the + fakeCString API to convert it back to ASCII string (as long + as the conversion is meaningful). + + Note that fakeCString return a heap allocated memory. It is + important to call deleteStr on fakeCString return value if + it is not longer required (or there will be memory leak). + + NOTE: Unfortunately, at the point when this document is written, + there is still no consensus on how Unicode is to be handled + in the textual representation of VCard/VCalendar. So, there + is no version of writeVObject and the parser to output and + input Unicode textual representation of VCard/VCalendar. + + +Example.vcf +----------- +line +number Input Text (example.vcf) +------ ---------- +1 BEGIN:VCALENDAR +2 DCREATED:19961102T100522 +3 GEO:0,0 +4 VERSION:1.0 +5 BEGIN:VEVENT +6 DTSTART:19961103T000000 +7 DTEND:20000101T000000 +8 DESCRIPTION;QUOTED-PRINTABLE:To be =0A= +9 or =0A= +10 not to be +11 STATUS:O.K. +12 X-ACTION:No action required +13 DALARM:19961103T114500;5;3;Enjoy +14 MALARM:19970101T120000;;;johny@nowhere.com;Call Mom. +15 END:VEVENT +16 +17 BEGIN:VTODO +18 DUE:19960614T0173000 +19 DESCRIPTION:Relex. +20 END:VTODO +21 +22 END:VCALENDAR +23 +24 BEGIN:VCARD +25 N:Alden;Roland +26 FN:Roland H. Alden +27 ORG:AT&T;Versit Project Office +28 TITLE:Consultant +29 EMAIL;WORK;PREF;INTERNET:ralden@ralden.com +30 LABEL;DOM;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A= +31 Suite 2208=0A= +32 One Pine Street=0A= +33 San Francisco, CA 94111 +34 LABEL;POSTAL;PARCEL;HOME;WORK;QUOTED-PRINTABLE:Roland H. Alden=0A= +35 Suite 2208=0A= +36 One Pine Street=0A= +37 San Francisco, CA 94111=0A= +38 U.S.A. +39 TEL;WORK;PREF;MSG:+1 415 296 9106 +40 TEL;WORK;FAX:+1 415 296 9016 +41 TEL;MSG;CELL:+1 415 608 5981 +42 ADR:;Suite 2208;One Pine Street;San Francisco;CA;94111;U.S.A. +43 SOUND:ROW-LAND H ALL-DIN +44 LOGO;GIF;BASE64: +45 R0lGODdhpgBOAMQAAP///+/v797e3s7Ozr29va2trZycnIyMjHt7e2NjY1JSUkJC + ... 30 lines of BASE64 data not shown here. +76 END:VCARD + + +VObject Representation of Example.vcf: +------------------------------------- +line +in +text +file VObject Tree as Printed by printVObject API +---- ------------------------------------------- +1 VCALENDAR +2 DCREATED="19961102T100522" +3 GEO="0,0" +4 VERSION="1.0" +5 VEVENT +6 DTSTART="19961103T000000" +7 DTEND="20000101T000000" +8 DESCRIPTION="To be +9 or +10 not to be" +8 QUOTED-PRINTABLE +11 STATUS="O.K." +12 X-ACTION="No action required" +13 DALARM +13 RUNTIME="19961103T114500" +13 SNOOZETIME="5" +13 REPEATCOUNT="3" +13 DISPLAYSTRING="Enjoy" +14 MALARM +14 RUNTIME="19970101T120000" +14 EMAIL="johny@nowhere.com" +14 NOTE="Call Mom" +17 VTODO +18 DUE="19960614T0173000" +19 DESCRIPTION="Relex." +24 VCARD +25 N +25 F="Alden" +25 G="Roland" +26 FN="Roland H. Alden" +27 ORG +27 ORGNAME="AT&T" +27 OUN="Versit Project Office" +28 TITLE="Consultant" +29 EMAIL="ralden@alden.com" +29 WORK +29 PREF +29 INTERNET +30 LABEL="Roland H. Alden +31 Suite 2208 +32 One Pine Street +33 San Francisco, CA 94111" +30 DOM +30 POSTAL +30 PARCEL +30 HOME +30 WORK +30 QUOTED-PRINTABLE +34 LABEL="Roland H. Alden +35 Suite 2208 +36 One Pine Street +37 San Francisco, CA 94111 +38 U.S.A." +34 POSTAL +34 PARCEL +34 HOME +34 WORK +34 QUOTED-PRINTABLE +39 TEL="+1 415 296 9106" +39 WORK +39 PREF +39 MSG +40 TEL="+1 415 296 9016" +40 WORK +40 FAX +41 TEL="+1 415 608 5981" +41 MSG +41 CELL +42 ADR +42 EXT ADD="Suite 2208" +42 STREET="One Pine Street" +42 L="San Francisco" +42 R="CA" +42 PC="94111" +42 C="U.S.A." +43 SOUND="ROW-LAND H ALL-DIN" +44 LOGO=[raw data] +44 GIF +44 BASE64 +44 DATASIZE=1482 diff --git a/src/libicalvcal/icalvcal.c b/src/libicalvcal/icalvcal.c index a4389603..01c32c6f 100644 --- a/src/libicalvcal/icalvcal.c +++ b/src/libicalvcal/icalvcal.c @@ -2,18 +2,9 @@ FILE: icalvcal.c CREATOR: eric 25 May 00 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original code is icalvcal.c @@ -118,11 +109,11 @@ static const char *get_string_value(VObject *object, int *free_string) static void convert_floating_time_to_utc(struct icaltimetype *itt) { struct tm tmp_tm, utc_tm; - time_t t; + icaltime_t t; /* We assume the floating time is using the current Unix timezone. - So we convert to a time_t using mktime(), and then back to a struct tm - using gmtime, so it is the UTC time. */ + So we convert to a icaltime_t using icalmktime(), and then back to a struct tm + using icalgmtime_r, so it is the UTC time. */ tmp_tm.tm_year = itt->year - 1900; tmp_tm.tm_mon = itt->month - 1; tmp_tm.tm_mday = itt->day; @@ -131,11 +122,11 @@ static void convert_floating_time_to_utc(struct icaltimetype *itt) tmp_tm.tm_sec = itt->second; tmp_tm.tm_isdst = -1; - /* Convert to a time_t. */ - t = mktime(&tmp_tm); + /* Convert to a icaltime_t. */ + t = icalmktime(&tmp_tm); /* Now convert back to a struct tm, but with a UTC time. */ - if (!gmtime_r(&t, &utc_tm)) { + if (!icalgmtime_r(&t, &utc_tm)) { *itt = itt->is_date ? icaltime_null_date () : icaltime_null_time (); return; } diff --git a/src/libicalvcal/icalvcal.h b/src/libicalvcal/icalvcal.h index 4986d20d..17a8d9b6 100644 --- a/src/libicalvcal/icalvcal.h +++ b/src/libicalvcal/icalvcal.h @@ -2,18 +2,10 @@ FILE: icalvcal.h CREATOR: eric 25 May 00 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef ICALVCAL_H diff --git a/src/libicalvcal/libical_vcal_export.h b/src/libicalvcal/libical_vcal_export.h index 0c744759..3404c28e 100644 --- a/src/libicalvcal/libical_vcal_export.h +++ b/src/libicalvcal/libical_vcal_export.h @@ -1,4 +1,9 @@ +/** + SPDX-FileCopyrightText: Allen Winter <winter@kde.org> + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 +*/ #ifndef LIBICAL_VCAL_EXPORT_H + #define LIBICAL_VCAL_EXPORT_H #if !defined(S_SPLINT_S) diff --git a/src/libicalvcal/vcaltmp.c b/src/libicalvcal/vcaltmp.c index 2562665d..4cbabeed 100644 --- a/src/libicalvcal/vcaltmp.c +++ b/src/libicalvcal/vcaltmp.c @@ -14,36 +14,10 @@ Note on APIs: */ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in @@ -76,7 +50,6 @@ VObject* vcsCreateVCal( return vcal; } - VObject* vcsAddEvent( VObject *vcal, char *start_date_time, @@ -111,7 +84,6 @@ VObject* vcsAddEvent( return vevent; } - VObject* vcsAddTodo( VObject *vcal, char *start_date_time, @@ -146,7 +118,6 @@ VObject* vcsAddTodo( return vtodo; } - VObject* vcsAddAAlarm( VObject *vevent, char *run_time, @@ -165,7 +136,6 @@ VObject* vcsAddAAlarm( return aalarm; } - VObject* vcsAddMAlarm( VObject *vevent, char *run_time, @@ -186,7 +156,6 @@ VObject* vcsAddMAlarm( return malarm; } - VObject* vcsAddDAlarm( VObject *vevent, char *run_time, @@ -205,7 +174,6 @@ VObject* vcsAddDAlarm( return dalarm; } - VObject* vcsAddPAlarm( VObject *vevent, char *run_time, @@ -224,7 +192,6 @@ VObject* vcsAddPAlarm( return palarm; } - #ifdef _TEST #if 0 @@ -333,5 +300,4 @@ void main() { #endif - /* end of source file vcaltmp.c */ diff --git a/src/libicalvcal/vcaltmp.h b/src/libicalvcal/vcaltmp.h index 4c1fe11e..69f9e82b 100644 --- a/src/libicalvcal/vcaltmp.h +++ b/src/libicalvcal/vcaltmp.h @@ -1,34 +1,8 @@ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in diff --git a/src/libicalvcal/vcc.c b/src/libicalvcal/vcc.c index 6fe0a55e..41daa87a 100644 --- a/src/libicalvcal/vcc.c +++ b/src/libicalvcal/vcc.c @@ -100,36 +100,10 @@ #line 2 "vcc.y" /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in @@ -147,7 +121,6 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. * be fixed in vcc.y and this file regenerated. */ - /* debugging utilities */ #ifdef __DEBUG #define DBG_(x) printf x @@ -191,7 +164,6 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #define yyrule mime_rule #define YYPREFIX "mime_" - #ifndef _NO_LINE_FOLDING #define _SUPPORT_LINE_FOLDING 1 #endif @@ -220,7 +192,6 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #define MAXLEVEL 10 /* max # of nested objects parseable */ /* (includes outermost) */ - /**** Global Variables ****/ int mime_lineNum, mime_numErrors; /* yyerror() can use these */ static VObject* vObjList; @@ -229,7 +200,6 @@ static VObject *curObj; static VObject* ObjStack[MAXLEVEL]; static int ObjStackTop; - /* A helpful utility for the rest of the app. */ #if defined(__CPLUSPLUS__) extern "C" { @@ -579,7 +549,6 @@ static int pushVObject(const char *prop) return 1; /*TRUE*/ } - /* This pops the recently built vCard off the stack and returns it. */ static VObject* popVObject() { @@ -594,7 +563,6 @@ static VObject* popVObject() return oldObj; } - static void enterValues(const char *value) { if (fieldedProp && *fieldedProp) { @@ -656,7 +624,6 @@ static void enterAttr(const char *s1, const char *s2) deleteStr(s1); deleteStr(s2); } - #define MAX_LEX_LOOKAHEAD_0 32 #define MAX_LEX_LOOKAHEAD 64 #define MAX_LEX_MODE_STACK_SIZE 10 @@ -744,7 +711,7 @@ static int lexGeta_(int i) } static void lexSkipLookahead() { - if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { + if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=((char) EOF)) { /* don't skip EOF. */ lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; lexBuf.len--; @@ -779,7 +746,7 @@ static int lexLookahead() { static int lexGetc() { int c = lexLookahead(); - if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { + if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=((char) EOF)) { /* EOF will remain in lookahead buffer */ lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; lexBuf.len--; @@ -829,7 +796,7 @@ static char* lexGetWord() { lexSkipWhite(); lexClearToken(); c = lexLookahead(); - while (c != EOF && !strchr("\t\n ;:=",c)) { + while (c != ((char) EOF) && !strchr("\t\n ;:=",c)) { lexAppendc(c); lexSkipLookahead(); c = lexLookahead(); @@ -841,7 +808,7 @@ static char* lexGetWord() { static void lexPushLookaheadc(int c) { int putptr; /* can't putback EOF, because it never leaves lookahead buffer */ - if (c == EOF) return; + if (((char) c) == ((char) EOF)) return; putptr = (int)lexBuf.getPtr - 1; if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; lexBuf.getPtr = (unsigned long)putptr; @@ -863,7 +830,7 @@ static char* lexLookaheadWord() { while (len < (MAX_LEX_LOOKAHEAD_0)) { c = lexGetc(); len++; - if (c == EOF || strchr("\t\n ;:=", c)) { + if (c == ((char) EOF) || strchr("\t\n ;:=", c)) { lexAppendc(0); /* restore lookahead buf. */ lexBuf.len += len; @@ -920,7 +887,7 @@ static char* lexGet1Value() { lexSkipWhite(); c = lexLookahead(); lexClearToken(); - while (c != EOF && c != ';') { + while (c != ((char) EOF) && c != ';') { if (c == '\n') { int a; lexSkipLookahead(); @@ -942,11 +909,10 @@ static char* lexGet1Value() { } lexAppendc(0); handleMoreRFC822LineBreak(c); - return c==EOF?0:lexStr(); + return c==((char) EOF)?0:lexStr(); } #endif - static int match_begin_name(int end) { char *n = lexLookaheadWord(); int token = ID; @@ -961,7 +927,6 @@ static int match_begin_name(int end) { return 0; } - #ifdef INCLUDEMFC void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) #else @@ -983,14 +948,18 @@ void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) lexBuf.maxToken = MAXTOKEN; lexBuf.strs = (char*)malloc(MAXTOKEN); lexBuf.strsLen = 0; - } static void finiLex() { + VObject* vobj, *topobj = 0; + while(vobj = popVObject(), vobj) { + topobj = vobj; + } + if(topobj) + cleanVObject(topobj); free(lexBuf.strs); } - /* This parses and converts the base64 format for binary encoding into * a decoded buffer (allocated with new). See RFC 1521. */ @@ -1036,9 +1005,9 @@ static char * lexGetDataFromBase64() else if (oldBytes) free(oldBytes); /* error recovery: skip until 2 adjacent newlines. */ DBG_(("db: invalid character 0x%x '%c'\n", c,c)); - if (c != EOF) { + if (c != ((char) EOF)) { c = lexGetc(); - while (c != EOF) { + while (c != ((char) EOF)) { if (c == '\n' && lexLookahead() == '\n') { ++mime_lineNum; break; @@ -1256,7 +1225,7 @@ int yylex() { ++mime_lineNum; continue; } - case EOF: return 0; + case ((char) EOF): return 0; break; default: { lexPushLookaheadc(c); @@ -1286,7 +1255,6 @@ int yylex() { return 0; } - /***************************************************************************/ /*** Public Functions ****/ /***************************************************************************/ @@ -1298,9 +1266,12 @@ static VObject* Parse_MIMEHelper() mime_lineNum = 1; vObjList = 0; curObj = 0; + curProp = 0; - if (yyparse() != 0) + if (yyparse() != 0) { + finiLex(); return 0; + } finiLex(); return vObjList; @@ -1312,7 +1283,6 @@ VObject* Parse_MIME(const char *input, unsigned long len) return Parse_MIMEHelper(); } - #ifdef INCLUDEMFC VObject* Parse_MIME_FromFile(CFile *file) @@ -1361,7 +1331,6 @@ VObject* Parse_MIME_FromFileName(const char *fname) #endif - static MimeErrorHandler mimeErrorHandler; void registerMimeErrorHandler(MimeErrorHandler me) @@ -1658,7 +1627,6 @@ case 23: #line 306 "vcc.y" { enterAttr(yystack.l_mark[-2].str,yystack.l_mark[0].str); - } break; case 25: diff --git a/src/libicalvcal/vcc.h b/src/libicalvcal/vcc.h index 5baf3115..d3a1f163 100644 --- a/src/libicalvcal/vcc.h +++ b/src/libicalvcal/vcc.h @@ -1,34 +1,8 @@ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in diff --git a/src/libicalvcal/vcc.y b/src/libicalvcal/vcc.y index 97c50ec7..b4c81760 100644 --- a/src/libicalvcal/vcc.y +++ b/src/libicalvcal/vcc.y @@ -1,36 +1,10 @@ %{ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in @@ -572,7 +546,7 @@ static int lexGeta_(int i) } static void lexSkipLookahead() { - if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { + if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=((char) EOF)) { /* don't skip EOF. */ lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; lexBuf.len--; @@ -607,7 +581,7 @@ static int lexLookahead() { static int lexGetc() { int c = lexLookahead(); - if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { + if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=((char) EOF)) { /* EOF will remain in lookahead buffer */ lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; lexBuf.len--; @@ -657,7 +631,7 @@ static char* lexGetWord() { lexSkipWhite(); lexClearToken(); c = lexLookahead(); - while (c != EOF && !strchr("\t\n ;:=",c)) { + while (c != ((char) EOF) && !strchr("\t\n ;:=",c)) { lexAppendc(c); lexSkipLookahead(); c = lexLookahead(); @@ -669,7 +643,7 @@ static char* lexGetWord() { static void lexPushLookaheadc(int c) { int putptr; /* can't putback EOF, because it never leaves lookahead buffer */ - if (c == EOF) return; + if (((char) c) == ((char) EOF)) return; putptr = (int)lexBuf.getPtr - 1; if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; lexBuf.getPtr = (unsigned long)putptr; @@ -691,7 +665,7 @@ static char* lexLookaheadWord() { while (len < (MAX_LEX_LOOKAHEAD_0)) { c = lexGetc(); len++; - if (c == EOF || strchr("\t\n ;:=", c)) { + if (c == ((char) EOF) || strchr("\t\n ;:=", c)) { lexAppendc(0); /* restore lookahead buf. */ lexBuf.len += len; @@ -748,7 +722,7 @@ static char* lexGet1Value() { lexSkipWhite(); c = lexLookahead(); lexClearToken(); - while (c != EOF && c != ';') { + while (c != ((char) EOF) && c != ';') { if (c == '\n') { int a; lexSkipLookahead(); @@ -770,7 +744,7 @@ static char* lexGet1Value() { } lexAppendc(0); handleMoreRFC822LineBreak(c); - return c==EOF?0:lexStr(); + return c==((char) EOF)?0:lexStr(); } #endif @@ -815,6 +789,10 @@ void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) } static void finiLex() { + VObject* vobj; + while(vobj = popVObject(), vobj) { + cleanVObject(vobj); + } free(lexBuf.strs); } @@ -864,9 +842,9 @@ static char * lexGetDataFromBase64() else if (oldBytes) free(oldBytes); /* error recovery: skip until 2 adjacent newlines. */ DBG_(("db: invalid character 0x%x '%c'\n", c,c)); - if (c != EOF) { + if (c != ((char) EOF)) { c = lexGetc(); - while (c != EOF) { + while (c != ((char) EOF)) { if (c == '\n' && lexLookahead() == '\n') { ++mime_lineNum; break; @@ -1084,7 +1062,7 @@ int yylex() { ++mime_lineNum; continue; } - case EOF: return 0; + case ((char) EOF): return 0; break; default: { lexPushLookaheadc(c); @@ -1126,9 +1104,12 @@ static VObject* Parse_MIMEHelper() mime_lineNum = 1; vObjList = 0; curObj = 0; + curProp = 0; - if (yyparse() != 0) + if (yyparse() != 0) { + finiLex(); return 0; + } finiLex(); return vObjList; diff --git a/src/libicalvcal/vobject.c b/src/libicalvcal/vobject.c index 10d0cf5a..9b2484fe 100644 --- a/src/libicalvcal/vobject.c +++ b/src/libicalvcal/vobject.c @@ -1,34 +1,8 @@ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in @@ -84,8 +58,6 @@ struct StrItem { const char** fieldedProp; - - /*---------------------------------------------------------------------- The following functions involve with memory allocation: newVObject @@ -144,7 +116,6 @@ void deleteStr(const char *p) free((void*)p); } - static StrItem* newStrItem(const char *s, StrItem *next) { StrItem *p = (StrItem*)malloc(sizeof(StrItem)); @@ -160,7 +131,6 @@ static void deleteStrItem(StrItem *p) free((void*)p); } - /*---------------------------------------------------------------------- The following function provide accesses to VObject's value. ----------------------------------------------------------------------*/ @@ -259,7 +229,6 @@ int vObjectValueType(VObject *o) return (int)VALUE_TYPE(o); } - /*---------------------------------------------------------------------- The following functions can be used to build VObject. ----------------------------------------------------------------------*/ @@ -457,8 +426,6 @@ VObject* addPropSizedValue(VObject *o, const char *p, const char *v, return addPropSizedValue_(o,p,dupStr(v,size),size); } - - /*---------------------------------------------------------------------- The following pretty print a VObject ----------------------------------------------------------------------*/ @@ -698,7 +665,6 @@ void cleanStrTbl() } } - struct PreDefProp { const char *name; const char *alias; @@ -937,7 +903,6 @@ static const struct PreDefProp propNames[] = { { 0,0,0,0 } }; - static const struct PreDefProp* lookupPropInfo(const char* str) { /* brute force for now, could use a hash table here. */ @@ -951,7 +916,6 @@ static const struct PreDefProp* lookupPropInfo(const char* str) return 0; } - const char* lookupProp_(const char* str) { int i; @@ -965,7 +929,6 @@ const char* lookupProp_(const char* str) return lookupStr(str); } - const char* lookupProp(const char* str) { int i; @@ -981,7 +944,6 @@ const char* lookupProp(const char* str) return lookupStr(str); } - /*---------------------------------------------------------------------- APIs to Output text form. ----------------------------------------------------------------------*/ @@ -1116,7 +1078,6 @@ static void initMemOFile(OFile *fp, char *s, int len) fp->fail = 0; } - static int writeBase64(OFile *fp, unsigned char *s, long len) { long cur = 0; @@ -1190,8 +1151,6 @@ static void writeQPString(OFile *fp, const char *s) } } - - static void writeVObject_(OFile *fp, VObject *o); static void writeValue(OFile *fp, VObject *o, unsigned long size,int quote) diff --git a/src/libicalvcal/vobject.h b/src/libicalvcal/vobject.h index 7541be58..72cbc58f 100644 --- a/src/libicalvcal/vobject.h +++ b/src/libicalvcal/vobject.h @@ -1,34 +1,8 @@ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in diff --git a/src/php/Makefile b/src/php/Makefile index f371a382..7eab507e 100644 --- a/src/php/Makefile +++ b/src/php/Makefile @@ -1,13 +1,16 @@ +# SPDX-FileCopyrightText: Copyright Contributors to the libical project +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + all: LibicalWrap.so LibicalWrap.so: LibicalWrap.o - gcc -shared -L/usr/lib -rdynamic LibicalWrap.o ../libical/.libs/libical.a ../libicalss/.libs/libicalss.a -o LibicalWrap.so + gcc -shared -L/usr/lib -rdynamic LibicalWrap.o ../libical/.libs/libical.a ../libicalss/.libs/libicalss.a -o LibicalWrap.so LibicalWrap.o: LibicalWrap.c gcc -fpic -I/usr/include/php4/TSRM/ -I/usr/include/php4/ -I/usr/include/php4/Zend -I/usr/include/php4/main -c LibicalWrap.c -o LibicalWrap.o LibicalWrap.c: LibicalWrap.i - swig -php -o LibicalWrap.c LibicalWrap.i + swig -php -o LibicalWrap.c LibicalWrap.i clean: rm LibicalWrap.so LibicalWrap.o LibicalWrap.c diff --git a/src/php/README b/src/php/README.txt index 15088204..15088204 100644 --- a/src/php/README +++ b/src/php/README.txt diff --git a/src/php/test.php b/src/php/test.php index 98ee7c8d..648e1dcd 100644 --- a/src/php/test.php +++ b/src/php/test.php @@ -1,5 +1,8 @@ <?php +// SPDX-FileCopyrightText: Copyright Contributors to the libical project +// SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + // '../../../../' is a dirty hack to be able to store LibicalWrap.so in my // homedir instead of in the machine-global directory diff --git a/src/python/Attendee.py b/src/python/Attendee.py index ed6fde46..349433f1 100644 --- a/src/python/Attendee.py +++ b/src/python/Attendee.py @@ -3,31 +3,19 @@ # FILE: Property.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from LibicalWrap import * diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index a5a593c3..24b9ba71 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + include_directories( ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/libical @@ -21,4 +24,3 @@ set_target_properties(LibicalWrap PROPERTIES install(TARGETS LibicalWrap DESTINATION lib) ########### install files ############### - diff --git a/src/python/ChangeLog b/src/python/ChangeLog index 1912df17..4cc5e099 100644 --- a/src/python/ChangeLog +++ b/src/python/ChangeLog @@ -3,19 +3,19 @@ * Component.py Added Calendar class. * Componeny.py Changed all component constructor so they cannot - take string arguments. Now, only NewComponent() can turn an iCal - string into a component. + take string arguments. Now, only NewComponent() can turn an iCal + string into a component. 2001-04-02 Eric Busboom <eric@civicknowledge.com> * Component.py removed arguments from the Event constructor, since - I presume that the Component derived classes will always be - constructed with no arguments. + I presume that the Component derived classes will always be + constructed with no arguments. * Property.py Split out Attendee, Organizer, Time, Duration and - Period into their own files. Moved remaining classes to Derived - Properties.pm + Period into their own files. Moved remaining classes to Derived + Properties.pm 2001-03-13 Eric Busboom <eric@civicknowledge.com> @@ -42,10 +42,10 @@ 2001-03-05 Eric Busboom <eric@civicknowledge.com> * Property.py Added a lot of exception code to signal failure to - create a Property. + create a Property. * DerivedProperties.py Added derived property classes for RDATE - and TRIGGER, two properties that can have one of two value types. + and TRIGGER, two properties that can have one of two value types. 2001-03-04 Eric Busboom <eric@civicknowledge.com> @@ -53,7 +53,7 @@ * Property.pm Added Property.ConstructorFailedError exception * Component.pm fixed bug in Collection.__setslice__. "," used - instead of ":" + instead of ":" 2001-03-04 Patrick Lewis <plewis@inetarena.com> @@ -80,23 +80,23 @@ * Property Added __del__ * Component Component.properties() now caches properties that it - constructs, so two calls to properties() to that get the same - icalproperty will also get the same Property. + constructs, so two calls to properties() to that get the same + icalproperty will also get the same Property. * Property Added Property.__cmp__ to test equality of properties - based on ical string values + based on ical string values 2001-02-27 Eric Busboom <eric@civicknowledge.com> * Property Added Property.ref() to set/get the reference to the - Property's internal icalproperty + Property's internal icalproperty * Property Property._update_value now changes the icalproperty - value if a reference has been set. + value if a reference has been set. * Component re-instituted Component.properties(). The routine now - adds a 'ref' key to the dict that holds the python pointer - string. The C hex value of the pointer is in the 'pid' key + adds a 'ref' key to the dict that holds the python pointer + string. The C hex value of the pointer is in the 'pid' key 2001-02-27 Patrick Lewis <plewis@inetarena.com> @@ -117,10 +117,10 @@ * Libical.py Added test routine for time, time_test() * Libical.py Remove end of line chars ('\r\n" ) from - Property._str__. Caller should add these lines itself + Property._str__. Caller should add these lines itself * Liical.py CHanges Time._update_values to set time VALUE type - based on use of is_date, rather than length of string. + based on use of is_date, rather than length of string. * Libical.py Removed call to _update_value in TIme::timezone diff --git a/src/python/Collection.py b/src/python/Collection.py index 15ae8b7e..1e911dc9 100644 --- a/src/python/Collection.py +++ b/src/python/Collection.py @@ -3,19 +3,13 @@ # FILE: Collection.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from types import * diff --git a/src/python/Component.py b/src/python/Component.py index 598e4977..91043905 100644 --- a/src/python/Component.py +++ b/src/python/Component.py @@ -3,30 +3,10 @@ # FILE: Component.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: -# -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt -# -# Or: -# -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ - -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: -# -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html -# -# Or: -# -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 #====================================================================== from LibicalWrap import * diff --git a/src/python/DerivedProperties.py b/src/python/DerivedProperties.py index 3a64f96f..879163d5 100644 --- a/src/python/DerivedProperties.py +++ b/src/python/DerivedProperties.py @@ -3,19 +3,13 @@ # FILE: DerivedProperties.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from Property import Property diff --git a/src/python/Duration.py b/src/python/Duration.py index 8997f59d..95260e03 100644 --- a/src/python/Duration.py +++ b/src/python/Duration.py @@ -3,19 +3,13 @@ # FILE: Duration.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #=============================================================== from LibicalWrap import * diff --git a/src/python/Error.py b/src/python/Error.py index 47fa0e7a..9104344b 100644 --- a/src/python/Error.py +++ b/src/python/Error.py @@ -2,31 +2,19 @@ # FILE: Error.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #=========================================================== class LibicalError(Exception): diff --git a/src/python/Gauge.py b/src/python/Gauge.py index 44954006..abfa1c77 100644 --- a/src/python/Gauge.py +++ b/src/python/Gauge.py @@ -3,19 +3,13 @@ # FILE: Gauge.py # CREATOR: mtearle # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from LibicalWrap import * diff --git a/src/python/Libical.py b/src/python/Libical.py index 20a2b975..ff4d7e18 100644 --- a/src/python/Libical.py +++ b/src/python/Libical.py @@ -3,19 +3,13 @@ # FILE: Libical.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from LibicalWrap import ICAL_PACKAGE, ICAL_VERSION diff --git a/src/python/LibicalWrap.i b/src/python/LibicalWrap.i index 070a6d5b..a0970428 100644 --- a/src/python/LibicalWrap.i +++ b/src/python/LibicalWrap.i @@ -2,17 +2,9 @@ /*====================================================================== FILE: ical.i - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - https://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom diff --git a/src/python/LibicalWrap_icaltime.i b/src/python/LibicalWrap_icaltime.i index f82a7706..ada94293 100644 --- a/src/python/LibicalWrap_icaltime.i +++ b/src/python/LibicalWrap_icaltime.i @@ -2,17 +2,9 @@ /*====================================================================== FILE: LibicalWrap_icaltime.i - (C) COPYRIGHT 2010 Glenn Washburn + SPDX-FileCopyrightText: 2010 Glenn Washburn - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - https://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Glenn Washburn (crass@berlios.de) @@ -193,4 +185,3 @@ _swig_set_properties(icaltimetype, icaltimetype_props) %} // TODO: Add icaltime_span_* to icaltime_spantype - diff --git a/src/python/LibicalWrap_icaltimezone.i b/src/python/LibicalWrap_icaltimezone.i index 320369cd..68f25219 100644 --- a/src/python/LibicalWrap_icaltimezone.i +++ b/src/python/LibicalWrap_icaltimezone.i @@ -2,17 +2,9 @@ /*====================================================================== FILE: LibicalWrap_icaltimezone.i - (C) COPYRIGHT 2010 Glenn Washburn + SPDX-FileCopyrightText: 2010 Glenn Washburn - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - https://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Glenn Washburn (crass@berlios.de) diff --git a/src/python/Period.py b/src/python/Period.py index 60c2f304..c5ed6b20 100644 --- a/src/python/Period.py +++ b/src/python/Period.py @@ -3,19 +3,13 @@ # FILE: Period.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #=========================================================== from LibicalWrap import * diff --git a/src/python/Property.py b/src/python/Property.py index 430b37aa..4d060e14 100644 --- a/src/python/Property.py +++ b/src/python/Property.py @@ -3,19 +3,13 @@ # FILE: Property.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from LibicalWrap import * diff --git a/src/python/Store.py b/src/python/Store.py index 8c6662a2..de47289a 100644 --- a/src/python/Store.py +++ b/src/python/Store.py @@ -3,19 +3,13 @@ # FILE: Store.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from LibicalWrap import * diff --git a/src/python/Time.py b/src/python/Time.py index f94770ce..1d20b8bd 100644 --- a/src/python/Time.py +++ b/src/python/Time.py @@ -3,19 +3,13 @@ # FILE: Time.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from LibicalWrap import * diff --git a/src/python/__init__.py b/src/python/__init__.py index 0f399441..1fdaee4b 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -3,19 +3,13 @@ # FILE: __init__.py # CREATOR: glenn # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== from Libical import * diff --git a/src/python/test.py b/src/python/test.py index 2de1fe61..cb4e83ad 100644 --- a/src/python/test.py +++ b/src/python/test.py @@ -3,19 +3,13 @@ # FILE: test.py # CREATOR: eric # -# (C) COPYRIGHT 2001, Eric Busboom <eric@civicknowledge.com> -# (C) COPYRIGHT 2001, Patrick Lewis <plewis@inetarena.com> +# SPDX-FileCopyrightText: 2001, Eric Busboom <eric@civicknowledge.com> +# SPDX-FileCopyrightText: 2001, Patrick Lewis <plewis@inetarena.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ #====================================================================== import LibicalWrap diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 9e008c86..fa0bcf9b 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Allen Winter <winter@kde.org> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src @@ -20,6 +23,7 @@ set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) set(TEST_DATADIR "\"${CMAKE_SOURCE_DIR}/test-data\"") add_definitions(-DTEST_DATADIR=${TEST_DATADIR} -DTEST_ZONEDIR="${CMAKE_SOURCE_DIR}/zoneinfo") +# Set properties for the test macro(setprops _name) if(UNIX) set_tests_properties(${_name} PROPERTIES @@ -61,7 +65,9 @@ macro(buildme _name _srcs) target_link_libraries(${_name} ical_cxx icalss_cxx) endif() - target_link_libraries(${_name} ${CMAKE_THREAD_LIBS_INIT}) + if(DEFINED CMAKE_THREAD_LIBS_INIT) + target_link_libraries(${_name} ${CMAKE_THREAD_LIBS_INIT}) + endif() if(ICU_FOUND) target_link_libraries(${_name} ${ICU_LIBRARIES}) endif() @@ -70,6 +76,7 @@ macro(buildme _name _srcs) endif() endmacro() +# Build the test and add the test, making sure the test properties are set macro(testme _name _srcs) buildme(${_name} "${_srcs}") add_test(NAME ${_name} COMMAND ${_name}) @@ -96,6 +103,8 @@ set(regression_SRCS regression-utils.c regression-recur.c regression-storage.c + test-malloc.c + test-malloc.h ) if(WITH_CXX_BINDINGS) list(APPEND regression_SRCS regression-cxx.cpp) @@ -108,10 +117,10 @@ set(parser_SRCS icaltestparser.c) buildme(parser "${parser_SRCS}") file(GLOB TEST_FILES ${CMAKE_SOURCE_DIR}/test-data/*.ics) -foreach(TEST_FILE ${TEST_FILES}) - get_filename_component(TEST_NAME ${TEST_FILE} NAME_WE) - add_test(NAME parser-${TEST_NAME} COMMAND parser ${TEST_FILE}) - setprops(parser-${TEST_NAME}) +foreach(test_file ${TEST_FILES}) + get_filename_component(test_name ${test_file} NAME_WE) + add_test(NAME parser-${test_name} COMMAND parser ${test_file}) + setprops(parser-${test_name}) endforeach() ########### next target ############### @@ -177,7 +186,8 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS 3.14) set(CMAKE_COMPARE_FILES_IGNORE_EOL TRUE) endif() if(NOT WIN32 OR CMAKE_COMPARE_FILES_IGNORE_EOL) - if(NOT CYGWIN AND NOT USE_32BIT_TIME_T) #ignore_eol doesn't work on Cygwin. tests for years greater than 2037 will fail + #ignore_eol doesn't work on Cygwin. testing years greater than 2037 will fail + if(NOT CYGWIN AND NOT USE_32BIT_TIME_T) set(icalrecurtest_SRCS icalrecur_test.c) add_executable(icalrecurtest ${icalrecurtest_SRCS}) target_link_libraries(icalrecurtest ical icalss icalvcal) diff --git a/src/test/builtin_timezones.c b/src/test/builtin_timezones.c index 3ceb462d..334b683a 100644 --- a/src/test/builtin_timezones.c +++ b/src/test/builtin_timezones.c @@ -2,18 +2,10 @@ FILE: builtin_timezones.c CREATOR: Milan Crha 26 November 2014 - (C) COPYRIGHT 2014 Milan Crha <mcrha@redhat.com> + SPDX-FileCopyrightText: 2014 Milan Crha <mcrha@redhat.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H diff --git a/src/test/copycluster.c b/src/test/copycluster.c index 282d0fc4..05961252 100644 --- a/src/test/copycluster.c +++ b/src/test/copycluster.c @@ -2,18 +2,9 @@ FILE: copycluster.c CREATOR: eric 15 January 2000 - (C) COPYRIGHT 2000 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/test/icalattach-leak.c b/src/test/icalattach-leak.c index d91aa398..3740742c 100644 --- a/src/test/icalattach-leak.c +++ b/src/test/icalattach-leak.c @@ -1,18 +1,9 @@ /*====================================================================== FILE: icalattach-leak.c - Copyright (C) 2019 Red Hat, Inc. <www.redhat.com> + SPDX-FileCopyrightText: 2019 Red Hat, Inc. <www.redhat.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Milan Crha ======================================================================*/ @@ -23,9 +14,7 @@ #include <stdio.h> -#define LIBICAL_GLIB_UNSTABLE_API #include "libical-glib/libical-glib.h" -#undef LIBICAL_GLIB_UNSTABLE_API static GSList *get_attachments(ICalComponent *comp) { diff --git a/src/test/icalrecur_test.c b/src/test/icalrecur_test.c index 3b1f0ceb..a236848d 100644 --- a/src/test/icalrecur_test.c +++ b/src/test/icalrecur_test.c @@ -2,18 +2,10 @@ FILE: icalrecur_test.c CREATOR: Ken Murchison 26 September 2014 - (C) COPYRIGHT 2000 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ /* @@ -670,7 +662,7 @@ int main(int argc, char *argv[]) } icalrecur_iterator_free(ritr); - free(rrule.rscale); + icalmemory_free_buffer(rrule.rscale); } fclose(fp); diff --git a/src/test/icaltestparser.c b/src/test/icaltestparser.c index c301a74f..c3a27abf 100644 --- a/src/test/icaltestparser.c +++ b/src/test/icaltestparser.c @@ -2,18 +2,9 @@ FILE: icaltestparser.c CREATOR: eric 20 June 1999 - (C) COPYRIGHT 1999 The Software Studio <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 The Software Studio <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom ======================================================================*/ diff --git a/src/test/icaltm_test.c b/src/test/icaltm_test.c index 141d49e4..b3ccad34 100644 --- a/src/test/icaltm_test.c +++ b/src/test/icaltm_test.c @@ -1,18 +1,9 @@ /*====================================================================== FILE: icaltm_test.c - Copyright (C) 2017 Red Hat, Inc. <www.redhat.com> + SPDX-FileCopyrightText: 2017 Red Hat, Inc. <www.redhat.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Milan Crha ======================================================================*/ diff --git a/src/test/libical-glib/CMakeLists.txt b/src/test/libical-glib/CMakeLists.txt index 4d239dba..2f88b115 100644 --- a/src/test/libical-glib/CMakeLists.txt +++ b/src/test/libical-glib/CMakeLists.txt @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Milan Crha <mcrha@redhat.com> +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + find_program(PYTHON3 python3) set_package_properties(PYTHON3 PROPERTIES TYPE REQUIRED PURPOSE "Required by the libical build system.") add_feature_info("libical-glib testing" PYTHON3 "python3 is required to run the regression tests") @@ -19,9 +22,22 @@ list(APPEND TEST_FILES ) if(PYTHON3) + set(GI_TYPELIB_PATH_STR "${CMAKE_BINARY_DIR}/src/libical-glib") + if(DEFINED GI_TYPELIB_PATH) + if($ENV{GI_TYPELIB_PATH}) + set(GI_TYPELIB_PATH_STR "${GI_TYPELIB_PATH_STR}:$ENV{GI_TYPELIB_PATH}") + endif() + endif() + set(LD_LIBRARY_PATH_STR "${LIBRARY_OUTPUT_PATH}") + if(DEFINED LD_LIBRARY_PATH) + if($ENV{LD_LIBRARY_PATH}) + set(LD_LIBRARY_PATH_STR "${LD_LIBRARY_PATH_STR}:$ENV{LD_LIBRARY_PATH}") + endif() + endif() + list(APPEND test_env - "GI_TYPELIB_PATH=${CMAKE_BINARY_DIR}/src/libical-glib;$ENV{GI_TYPELIB_PATH}" - "LD_LIBRARY_PATH=${LIBRARY_OUTPUT_PATH};$ENV{LD_LIBRARY_PATH}" + "GI_TYPELIB_PATH=${GI_TYPELIB_PATH_STR}" + "LD_LIBRARY_PATH=${LD_LIBRARY_PATH_STR}" "ZONEINFO_DIRECTORY=${CMAKE_SOURCE_DIR}/zoneinfo" ) diff --git a/src/test/libical-glib/array.py b/src/test/libical-glib/array.py index 77d9550a..da3b26b2 100755..100644 --- a/src/test/libical-glib/array.py +++ b/src/test/libical-glib/array.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/attach.py b/src/test/libical-glib/attach.py index 4a5492ac..7bcb5583 100755..100644 --- a/src/test/libical-glib/attach.py +++ b/src/test/libical-glib/attach.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/component.py b/src/test/libical-glib/component.py index cbdb097e..13d6b104 100755..100644 --- a/src/test/libical-glib/component.py +++ b/src/test/libical-glib/component.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### @@ -183,25 +177,21 @@ def main(): #Traverse with external API. iter = parent.begin_component(ICalGLib.ComponentKind.VEVENT_COMPONENT); child_component = iter.deref(); - child_component.set_owner(parent); for i in range(0, count): prefix = "test" index = i+2; assert(child_component.get_summary() == prefix + str(index)); if (i != count-1): child_component = iter.next(); - child_component.set_owner(parent); iter = parent.end_component(ICalGLib.ComponentKind.VEVENT_COMPONENT); child_component = iter.prior(); - child_component.set_owner(parent); for i in range(0, count): prefix = "test" index = count + 1 - i; assert(child_component.get_summary() == prefix + str(index)); if (i != count - 1): child_component = iter.prior(); - child_component.set_owner(parent); #Traverse and remove with external API. iter = parent.begin_component(ICalGLib.ComponentKind.VEVENT_COMPONENT); diff --git a/src/test/libical-glib/comprehensive.py b/src/test/libical-glib/comprehensive.py index 94fdfb6f..4f3fe629 100755..100644 --- a/src/test/libical-glib/comprehensive.py +++ b/src/test/libical-glib/comprehensive.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/duration.py b/src/test/libical-glib/duration.py index 114970ad..b6a1ac78 100755..100644 --- a/src/test/libical-glib/duration.py +++ b/src/test/libical-glib/duration.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/error.py b/src/test/libical-glib/error.py index e501a984..e64de32a 100755..100644 --- a/src/test/libical-glib/error.py +++ b/src/test/libical-glib/error.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/misc.py b/src/test/libical-glib/misc.py index d10648b8..2cb59d44 100755..100644 --- a/src/test/libical-glib/misc.py +++ b/src/test/libical-glib/misc.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2019 Red Hat Inc. <www.redhat.com> +# SPDX-FileCopyrightText: 2019 Red Hat Inc. <www.redhat.com> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/parameter.py b/src/test/libical-glib/parameter.py index 5a0c6230..33cea40a 100755..100644 --- a/src/test/libical-glib/parameter.py +++ b/src/test/libical-glib/parameter.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/period.py b/src/test/libical-glib/period.py index bcc49706..1791a34d 100755..100644 --- a/src/test/libical-glib/period.py +++ b/src/test/libical-glib/period.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/property.py b/src/test/libical-glib/property.py index 23de9b5d..ee78467e 100755..100644 --- a/src/test/libical-glib/property.py +++ b/src/test/libical-glib/property.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/recurrence.py b/src/test/libical-glib/recurrence.py index c136224b..d00910ff 100755..100644 --- a/src/test/libical-glib/recurrence.py +++ b/src/test/libical-glib/recurrence.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/timezone.py b/src/test/libical-glib/timezone.py index ec027a1b..88fb6b01 100755..100644 --- a/src/test/libical-glib/timezone.py +++ b/src/test/libical-glib/timezone.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/libical-glib/value.py b/src/test/libical-glib/value.py index 7be64644..0cebbb7b 100755..100644 --- a/src/test/libical-glib/value.py +++ b/src/test/libical-glib/value.py @@ -3,18 +3,12 @@ ############################################################################### # -# Copyright (C) 2015 William Yu <williamyu@gnome.org> +# SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org> # -# This library is free software; you can redistribute it and/or modify -# it under the terms of either: +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 # -# The LGPL as published by the Free Software Foundation, version -# 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.txt # -# Or: # -# The Mozilla Public License Version 2.0. You may obtain a copy of -# the License at https://www.mozilla.org/MPL/ # ############################################################################### diff --git a/src/test/process.c b/src/test/process.c index db609b27..f2816154 100644 --- a/src/test/process.c +++ b/src/test/process.c @@ -2,18 +2,10 @@ FILE: process.c CREATOR: eric 11 February 2000 - (C) COPYRIGHT 2000 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H diff --git a/src/test/recur.c b/src/test/recur.c index 01552802..014ede09 100644 --- a/src/test/recur.c +++ b/src/test/recur.c @@ -2,7 +2,7 @@ FILE: recur.c CREATOR: ebusboom 8jun00 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> DESCRIPTION: @@ -10,16 +10,8 @@ ./recur ../../test-data/recur.txt - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -45,8 +37,8 @@ static void recur_callback(icalcomponent *comp, struct icaltime_span *span, void { _unused(comp); _unused(data); - printf("cb: %s", ctime(&span->start)); - printf(" %s\n", ctime(&span->end)); + printf("cb: %s", icalctime(&span->start)); + printf(" %s\n", icalctime(&span->end)); } int main(int argc, char *argv[]) @@ -57,7 +49,7 @@ int main(int argc, char *argv[]) icalproperty *desc, *dtstart, *rrule; struct icalrecurrencetype recur; icalrecur_iterator *ritr; - time_t tt; + icaltime_t tt; const char *file; icalerror_set_error_state(ICAL_PARSE_ERROR, ICAL_ERROR_NONFATAL); @@ -114,7 +106,7 @@ int main(int argc, char *argv[]) tt = icaltime_as_timet(start); - printf("#### %s\n", ctime(&tt)); + printf("#### %s\n", icalctime(&tt)); icalrecur_iterator_free(ritr); @@ -123,7 +115,7 @@ int main(int argc, char *argv[]) !icaltime_is_null_time(next); next = icalrecur_iterator_next(ritr)) { tt = icaltime_as_timet(next); - printf(" %s", ctime(&tt)); + printf(" %s", icalctime(&tt)); } icalrecur_iterator_free(ritr); diff --git a/src/test/regression-classify.c b/src/test/regression-classify.c index 7e5d4aa7..a5f3af0c 100644 --- a/src/test/regression-classify.c +++ b/src/test/regression-classify.c @@ -1,18 +1,10 @@ /*====================================================================== FILE: regression-classify.c - Copyright (C) 2002 Paul Lindner <lindner@users.sf.net> + SPDX-FileCopyrightText: 2002 Paul Lindner <lindner@users.sf.net> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H diff --git a/src/test/regression-component.c b/src/test/regression-component.c index 3e147e9e..388c53a4 100644 --- a/src/test/regression-component.c +++ b/src/test/regression-component.c @@ -1,18 +1,9 @@ /*====================================================================== FILE: regression-component.c - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom ======================================================================*/ @@ -310,9 +301,9 @@ static void print_span(int c, struct icaltime_span span) */ void test_icalcomponent_get_span() { - time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, + icaltime_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, Sat Nov 4 15:00:00 PST 2000 */ - time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 + icaltime_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 Sat Nov 4 16:00:00 PST 2000 */ struct icaldurationtype dur; struct icaltime_span span; @@ -321,7 +312,7 @@ void test_icalcomponent_get_span() int tnum = 0; /** test 0 - * Direct assigning time_t means they will be interpreted as UTC + * Direct assigning icaltime_t means they will be interpreted as UTC */ span.start = tm1; span.end = tm2; @@ -448,7 +439,7 @@ void test_icalcomponent_get_span() if (VERBOSE) print_span(tnum++, span); - int_is("null span", (int)span.start, 0); + int_is("start == end", (int)span.start, (int)span.end); icalcomponent_free(c); /** test 7 diff --git a/src/test/regression-cxx.cpp b/src/test/regression-cxx.cpp index 6bb33b3a..dbe3ae49 100644 --- a/src/test/regression-cxx.cpp +++ b/src/test/regression-cxx.cpp @@ -1,16 +1,8 @@ /** - (C) COPYRIGHT 2001, Critical Path + SPDX-FileCopyrightText: 2001, Critical Path - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ */ #ifdef HAVE_CONFIG_H diff --git a/src/test/regression-recur.c b/src/test/regression-recur.c index e11112e6..dee65679 100644 --- a/src/test/regression-recur.c +++ b/src/test/regression-recur.c @@ -2,20 +2,12 @@ FILE: regression-recur.c CREATOR: ebusboom 8jun00 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> DESCRIPTION: - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifdef HAVE_CONFIG_H @@ -69,8 +61,8 @@ static void recur_callback(icalcomponent *comp, struct icaltime_span *span, void _unused(comp); if (VERBOSE) { - printf("recur: %s", ctime(&span->start)); - printf(" %s", ctime(&span->end)); + printf("recur: %s", icalctime(&span->start)); + printf(" %s", icalctime(&span->end)); } *num_recurs = *num_recurs + 1; } @@ -83,7 +75,7 @@ void test_recur_file() icalproperty *desc, *dtstart, *rrule; struct icalrecurrencetype recur; icalrecur_iterator *ritr; - time_t tt; + icaltime_t tt; const char *file; int num_recurs_found = 0; icalfileset_options options = { O_RDONLY, 0644, 0, NULL }; @@ -147,7 +139,7 @@ void test_recur_file() tt = icaltime_as_timet(start); if (VERBOSE) - printf("#### %s\n", ctime(&tt)); + printf("#### %s\n", icalctime(&tt)); icalrecur_iterator_free(ritr); @@ -157,7 +149,7 @@ void test_recur_file() next = icalrecur_iterator_next(ritr)) { tt = icaltime_as_timet(next); if (VERBOSE) - printf(" %s", ctime(&tt)); + printf(" %s", icalctime(&tt)); } icalrecur_iterator_free(ritr); diff --git a/src/test/regression-storage.c b/src/test/regression-storage.c index f8cd11e1..b3c1f98d 100644 --- a/src/test/regression-storage.c +++ b/src/test/regression-storage.c @@ -2,20 +2,11 @@ FILE: regression-storage.c CREATOR: eric 03 April 1999 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> DESCRIPTION: - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom The original code is usecases.c diff --git a/src/test/regression-utils.c b/src/test/regression-utils.c index 431cef85..3536f0ad 100644 --- a/src/test/regression-utils.c +++ b/src/test/regression-utils.c @@ -1,18 +1,9 @@ /*====================================================================== FILE: regression-utils.c - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom ======================================================================*/ @@ -23,6 +14,9 @@ #include "libical/ical.h" +#include "test-malloc.h" +#include "regression.h" + #include <stdlib.h> int QUIET = 0; @@ -30,12 +24,12 @@ int VERBOSE = 1; static char ictt_str[1024]; -const char *ical_timet_string(const time_t t) +const char *ical_timet_string(const icaltime_t t) { struct tm tmp, stm; memset(&tmp, 0, sizeof(tmp)); - if (gmtime_r(&t, &tmp)) { + if (icalgmtime_r(&t, &tmp)) { stm = tmp; } else { memset(&stm, 0, sizeof(stm)); @@ -68,10 +62,10 @@ const char *ictt_as_string(struct icaltimetype t) char *icaltime_as_ctime(struct icaltimetype t) { - time_t tt; + icaltime_t tt; tt = icaltime_as_timet(t); - snprintf(ictt_str, sizeof(ictt_str), "%s", ctime(&tt)); + snprintf(ictt_str, sizeof(ictt_str), "%s", icalctime(&tt)); return ictt_str; } @@ -93,7 +87,7 @@ void die_on_errors_set(int val) die_on_errors = val; } -void _ok(const char *test_name, int success, char *file, int linenum, const char *test) +void _ok(const char *test_name, int success, const char *file, int linenum, const char *test) { testnumber++; @@ -114,7 +108,7 @@ void _ok(const char *test_name, int success, char *file, int linenum, const char } } -void _is(const char *test_name, const char *str1, const char *str2, char *file, int linenum) +void _is(const char *test_name, const char *str1, const char *str2, const char *file, int linenum) { int diff; @@ -135,7 +129,7 @@ void _is(const char *test_name, const char *str1, const char *str2, char *file, } } -void _int_is(char *test_name, int i1, int i2, char *file, int linenum) +void _int_is(const char *test_name, int i1, int i2, const char *file, int linenum) { _ok(test_name, (i1 == i2), file, linenum, ""); @@ -196,7 +190,6 @@ int test_end(void) printf("%s%d/%d ", prefix, this_set, failed_tests[i].test); } printf("\n"); - } else { printf("\n All Tests Successful.\n"); } @@ -204,6 +197,24 @@ int test_end(void) return failed; } +/** + * Bring all memory that is allocated as side effect into a stable state, so we can calculate + * stable memory allocation statistics. + */ +static void cleanup_nondeterministic_memory() { + + // icalerrno_return() allocates a buffer on it's first use per thread. Let's allocate it + // now, so it doesn't disturb our test statistics. + icalerrno_return(); + + // Built-in timezones are cached by libical. By freeing them, they don't influence our statistics. + icaltimezone_free_builtin_timezones(); + + // Memory that was added to the ring buffer is not required to be freed by the caller, so + // we free it here to keep our statistics clean. + icalmemory_free_ring(); +} + void test_run(const char *test_name, void (*test_fcn) (void), int do_test, int headeronly) { static int test_set = 1; @@ -212,7 +223,29 @@ void test_run(const char *test_name, void (*test_fcn) (void), int do_test, int h test_header(test_name, test_set); if (!headeronly && (do_test == 0 || do_test == test_set)) { + + struct testmalloc_statistics mem_statistics; + + // Clean up cached and other kind of non-deterministic memory. + cleanup_nondeterministic_memory(); + + // Now that we are in a stable state, reset the memory statistics and start counting. + testmalloc_reset(); + + // Run the test. (*test_fcn) (); + + // Before getting the statistics, clean up any non-deterministic memory again, so it + // doesn't influence the statistics. + cleanup_nondeterministic_memory(); + + // Now we should get clean statistics. + testmalloc_get_statistics(&mem_statistics); + + ok("no memory leaked", + (mem_statistics.mem_allocated_current == 0) && + (mem_statistics.blocks_allocated == 0)); + if (!QUIET) printf("\n"); } diff --git a/src/test/regression.c b/src/test/regression.c index 2b94dc1c..da3ba9af 100644 --- a/src/test/regression.c +++ b/src/test/regression.c @@ -2,18 +2,9 @@ FILE: regression.c CREATOR: eric 03 April 1999 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The original author is Eric Busboom The original code is regression.c @@ -27,6 +18,7 @@ #include "regression.h" #include "libical/astime.h" +#include "test-malloc.h" #include "libical/ical.h" #include "libicalss/icalss.h" #include "libicalvcal/icalvcal.h" @@ -806,7 +798,7 @@ void test_memory() ok("final buffer size == 806", (bufsize == 806)); - free(f); + icalmemory_free_buffer(f); bufsize = 4; @@ -895,7 +887,7 @@ void test_memory() if (VERBOSE) printf("Char-by-Char buffer: %s\n", f); - free(f); + icalmemory_free_buffer(f); for (i = 0; i < 100; i++) { f = icalmemory_tmp_buffer(bufsize); @@ -1145,7 +1137,15 @@ void test_restriction() icalproperty_vanew_dtend(atime, icalparameter_new_tzid("America/New_York"), (void *)0), - icalproperty_new_location("1CP Conference Room 4350"), (void *)0), (void *)0); + icalproperty_new_location("1CP Conference Room 4350"), + icalcomponent_vanew(ICAL_VALARM_COMPONENT, + icalproperty_new_action(ICAL_ACTION_EMAIL), + icalproperty_new_repeat(0), + icalcomponent_vanew(ICAL_VLOCATION_COMPONENT, + (void *)0), + (void *)0), + (void *)0), + (void *)0); valid = icalrestriction_check(comp); @@ -1217,17 +1217,17 @@ void print_occur(struct icalrecurrencetype recur, struct icaltimetype start) struct icaltimetype next; icalrecur_iterator *ritr; - time_t tt = icaltime_as_timet(start); + icaltime_t tt = icaltime_as_timet(start); printf("#### %s\n", icalrecurrencetype_as_string(&recur)); - printf("#### %s\n", ctime(&tt)); + printf("#### %s\n", icalctime(&tt)); ritr = icalrecur_iterator_new(recur, start); for (next = icalrecur_iterator_next(ritr); !icaltime_is_null_time(next); next = icalrecur_iterator_next(ritr)) { tt = icaltime_as_timet(next); - printf(" %s", ctime(&tt)); + printf(" %s", icalctime(&tt)); } icalrecur_iterator_free(ritr); @@ -1237,7 +1237,7 @@ void test_recur() { struct icalrecurrencetype rt; struct icaltimetype start; - time_t array[25]; + icaltime_t array[25]; int i; rt = icalrecurrencetype_from_string( @@ -1258,7 +1258,7 @@ void test_recur() for (i = 0; i < 25 && array[i] != 0; i++) { if (VERBOSE) { - printf(" %s", ctime(&(array[i]))); + printf(" %s", icalctime(&(array[i]))); } } /* test_increment();*/ @@ -1350,19 +1350,19 @@ void test_recur_encode_by_month() void test_expand_recurrence() { - time_t arr[10]; - time_t now = 931057385; + icaltime_t arr[10]; + icaltime_t now = 931057385; int i, numfound = 0; icalrecur_expand_recurrence("FREQ=MONTHLY;BYDAY=MO,WE", now, 5, arr); if (VERBOSE) - printf("Start %s", ctime(&now)); + printf("Start %s", icalctime(&now)); for (i = 0; i < 5; i++) { numfound++; if (VERBOSE) - printf("i=%d %s\n", i, ctime(&arr[i])); + printf("i=%d %s\n", i, icalctime(&arr[i])); } int_is("Get an array of 5 items", numfound, 5); } @@ -1391,7 +1391,7 @@ void icalrecurrencetype_test() struct icalrecurrencetype r = icalvalue_get_recur(v); struct icaltimetype t = icaltime_from_timet_with_zone(time(0), 0, NULL); struct icaltimetype next; - time_t tt; + icaltime_t tt; struct icalrecur_iterator_impl *itr = (struct icalrecur_iterator_impl *)icalrecur_iterator_new(r, t); @@ -1401,7 +1401,7 @@ void icalrecurrencetype_test() next = icalrecur_iterator_next(itr); tt = icaltime_as_timet(next); - printf("%s", ctime(&tt)); + printf("%s", icalctime(&tt)); } while (!icaltime_is_null_time(next)); @@ -1767,8 +1767,8 @@ void do_test_time(const char *zone) { struct icaltimetype ictt, icttutc, icttzone, icttdayl, icttla, icttny, icttphoenix, icttlocal, icttnorm; - time_t tt, tt2, tt_p200; - time_t offset_tz; + icaltime_t tt, tt2, tt_p200; + icaltime_t offset_tz; icalvalue *v; short day_of_week, start_day_of_week, day_of_year; icaltimezone *azone, *utczone; @@ -1781,7 +1781,7 @@ void do_test_time(const char *zone) /* Test new API */ if (VERBOSE) { - printf("\n---> From time_t \n"); + printf("\n---> From icaltime_t \n"); } tt = 1025127869; /* stick with a constant... Wed, 26 Jun 2002 21:44:29 GMT */ @@ -1791,7 +1791,7 @@ void do_test_time(const char *zone) } ictt = icaltime_from_timet_with_zone(tt, 0, NULL); - str_is("Floating time from time_t", ictt_as_string(ictt), "2002-06-26 21:44:29 (floating)"); + str_is("Floating time from icaltime_t", ictt_as_string(ictt), "2002-06-26 21:44:29 (floating)"); ictt = icaltime_from_timet_with_zone(tt, 0, azone); #if ADD_TESTS_REQUIRING_INVESTIGATION @@ -1869,7 +1869,7 @@ void do_test_time(const char *zone) tt = icaltime_as_timet(ictt); - ok("test icaltime -> time_t for 20001103T183030Z", (tt == 973276230)); + ok("test icaltime -> icaltime_t for 20001103T183030Z", (tt == 973276230)); /* Fri Nov 3 10:30:30 PST 2000 in PST Fri Nov 3 18:30:30 PST 2000 in UTC */ @@ -1894,7 +1894,7 @@ void do_test_time(const char *zone) /** add test case here.. **/ if (VERBOSE) { - printf("\n As time_t \n"); + printf("\n As icaltime_t \n"); } tt2 = icaltime_as_timet(ictt); @@ -1914,7 +1914,7 @@ void do_test_time(const char *zone) printf("20001103T183030 : %s\n", ictt_as_string(icttlocal)); } - offset_tz = (time_t) (-icaltimezone_get_utc_offset_of_utc_time(azone, &ictt, 0)); + offset_tz = (icaltime_t) (-icaltimezone_get_utc_offset_of_utc_time(azone, &ictt, 0)); if (VERBOSE) printf("offset_tz : %ld\n", (long)offset_tz); @@ -2012,7 +2012,7 @@ void do_test_time(const char *zone) icaltimezone_get_builtin_timezone("America/Phoenix")); if (VERBOSE) { - printf("Orig (ctime): %s\n", ical_timet_string(tt)); + printf("Orig (icalctime): %s\n", ical_timet_string(tt)); printf("Orig (ical) : %s\n", ictt_as_string(ictt)); printf("UTC : %s\n", ictt_as_string(icttutc)); printf("Los Angeles : %s\n", ictt_as_string(icttla)); @@ -2025,7 +2025,7 @@ void do_test_time(const char *zone) if (VERBOSE) { printf("\n Daylight Savings \n"); - printf("Orig (ctime): %s\n", ical_timet_string(tt)); + printf("Orig (icalctime): %s\n", ical_timet_string(tt)); printf("Orig (ical) : %s\n", ictt_as_string(ictt)); printf("NY : %s\n", ictt_as_string(icttny)); } @@ -2053,7 +2053,7 @@ void do_test_time(const char *zone) icaltimezone_get_builtin_timezone("America/Los_Angeles")); if (VERBOSE) { - printf("\nOrig (ctime): %s\n", ical_timet_string(tt)); + printf("\nOrig (icalctime): %s\n", ical_timet_string(tt)); printf("Orig (ical) : %s\n", ictt_as_string(ictt)); printf("LA : %s\n", ictt_as_string(icttla)); } @@ -2270,12 +2270,12 @@ void test_overlaps() { icalcomponent *cset, *c; icalset *set; - time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, + icaltime_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, Sat Nov 4 15:00:00 PST 2000 */ - time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 + icaltime_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 Sat Nov 4 16:00:00 PST 2000 */ - time_t hh = 1800; /* one half hour */ + icaltime_t hh = 1800; /* one half hour */ icalfileset_options options = { O_RDONLY, 0644, 0, NULL }; set = icalset_new(ICAL_FILE_SET, TEST_DATADIR "/overlaps.ics", &options); @@ -2722,16 +2722,14 @@ void test_recur_parser() rt = icalrecurrencetype_from_string(str); icalerror_restore("MALFORMEDDATA", es); ok(str, rt.freq == ICAL_NO_RECURRENCE); - free(v); + icalmemory_free_buffer(v); } - static int test_juldat_caldat_instance(long year, int month, int day) { struct icaltimetype t; struct ut_instant originalInstant; - memset(&t, 0, sizeof(t)); t.year = year; t.month = month; @@ -2808,7 +2806,6 @@ void test_juldat_caldat() { ok("juldat and caldat return the expected values for random input values", failed == 0); } - char *ical_strstr(const char *haystack, const char *needle) { return strstr(haystack, needle); @@ -2872,7 +2869,7 @@ void test_doy() stm.tm_year = tt1.year - 1900; stm.tm_isdst = -1; - (void)mktime(&stm); + (void)icalmktime(&stm); doy = icaltime_day_of_year(tt1); @@ -4252,6 +4249,8 @@ void test_vcal(void) if (comp) { icalcomponent_free(comp); } + + cleanVObject(vcal); } } @@ -4378,6 +4377,50 @@ void test_comma_in_quoted_value(void) icalcomponent_free(c); } +void test_geo_props(void) +{ + int estate; + icalcomponent *c; + icalproperty *p; + + c = icalparser_parse_string("BEGIN:VEVENT\n" "GEO:49.42612;7.75473\n" "END:VEVENT\n"); + ok("icalparser_parse_string()", (c != NULL)); + if (!c) { + exit(EXIT_FAILURE); + } + if (VERBOSE) + printf("%s", icalcomponent_as_ical_string(c)); + p = icalcomponent_get_first_property(c, ICAL_GEO_PROPERTY); + str_is("icalproperty_get_value_as_string() works", + icalproperty_get_value_as_string(p), "49.42612;7.75473"); + icalcomponent_free(c); + + c = icalparser_parse_string("BEGIN:VEVENT\n" "GEO:-0;+0\n" "END:VEVENT\n"); + ok("icalparser_parse_string()", (c != NULL)); + if (!c) { + exit(EXIT_FAILURE); + } + if (VERBOSE) + printf("%s", icalcomponent_as_ical_string(c)); + p = icalcomponent_get_first_property(c, ICAL_GEO_PROPERTY); + str_is("icalproperty_get_value_as_string() works", + icalproperty_get_value_as_string(p), "-0;+0"); + icalcomponent_free(c); + + estate = icalerror_get_errors_are_fatal(); + icalerror_set_errors_are_fatal(0); + c = icalparser_parse_string("BEGIN:VEVENT\n" "GEO:-0a;+0\n" "END:VEVENT\n"); + if (!c) { + exit(EXIT_FAILURE); + } + if (VERBOSE) + printf("%s", icalcomponent_as_ical_string(c)); + p = icalcomponent_get_first_property(c, ICAL_GEO_PROPERTY); + ok("expected fail icalcomponent_get_first_property()", (p == NULL)); + icalcomponent_free(c); + icalerror_set_errors_are_fatal(estate); +} + void test_zoneinfo_stuff(void) { #if defined(HAVE_SETENV) @@ -4621,7 +4664,7 @@ void test_timezone_from_builtin(void) icaltimezone *zone; struct icaltimetype dtstart, dtend, due; char *strcomp, *tzidprefix, *prevslash = NULL, *prevprevslash = NULL, *p; - int len; + size_t len; zone = icaltimezone_get_builtin_timezone("America/New_York"); tzidprefix = strdup(icaltimezone_get_tzid (zone)); @@ -4662,7 +4705,7 @@ void test_timezone_from_builtin(void) comp = icaltimezone_get_component(zone); strcomp = icalcomponent_as_ical_string_r(comp); comp = icalcomponent_new_from_string(strcomp); - free(strcomp); + icalmemory_free_buffer(strcomp); ok("VTIMEZONE icalcomponent_new_from_string()", (comp != NULL)); @@ -4877,6 +4920,308 @@ static void test_builtin_compat_tzid (void) icaltimezone_free_builtin_timezones(); } +static void test_vcc_vcard_parse(void) +{ + /* Two VCARD-s, because some arches can parse the first and some the second. */ + const char *vcard1 = + "BEGIN:VCARD\r\n" + "VERSION:3.0\r\n" + "NOTE:\r\n" + "FN:Xxxx\r\n" + "N:;Xxxx;;;\r\n" + "END:VCARD"; + const char *vcard2 = + "BEGIN:VCARD\r\n" + "VERSION:3.0\r\n" + "X-XXX-ORIGINAL-VCARD:\r\n" + "X-XXX-KIND:XX_XXXXXXXX\r\n" + "NOTE:\r\n" + "X-XXXXXXXXX-FILE-AS:Xxxxxx\r\n" + "FN:Xxxxxx\r\n" + "N:;Xxxxxx;;;\r\n" + "X-XXX-XXXXXXXXX:\r\n" + "END:VCARD"; + const char *vcalendar = + "BEGIN:VCALENDAR\r\n" + "BEGIN:VEVENT\r\n" + "UID:123\r\n" + "SUMMARY:Summary\r\n" + "DTSTAMP:20210803T063522Z\r\n" + "DTSTART;VALUE=DATE:20210902\r\n" + "END:VEVENT\r\n" + "END:VCALENDAR\r\n"; + const char *vcalendar_broken = + "BEGIN:VCALENDAR\r\n" + "BEGIN:VTIMEZONE\r\n" + "TZID:tz/id\r\n" + "BEGIN:STANDARD\r\n" + "TZNAME:PMT\r\n" + "TZOFFSETFROM:+005744\r\n" + "TZOFFSETTO:+005744\r\n" + "DTSTART:18500101T000000\r\n" + "END:STANDARD\r\n" + "BEGIN:STANDARD\r\n" + "TZNAME:CET\r\n" + "TZOFFSETFROM:+005744\r\n" + "TZOFFSETTO:+0100\r\n" + "DTSTART:18911001T000000\r\n" + "END:STANDARD\r\n" + "BEGIN:DAYLIGHT\r\n" + "TZNAME:CEST\r\n" + "TZOFFSETFROM:+0100\r\n" + "TZOFFSETTO:+0200\r\n" + "DTSTART:19160430T230000\r\n" + "END:DAYLIGHT\r\n" + "END:VTIMEZONE\r\n" + "BEGIN:VEVENT\r\n" + "UID:321\r\n" + "SUMMARY:Summary\r\n" + "DTSTAMP:20210803T063522Z\r\n" + "DTSTART;VALUE=DATE:20210902\r\n" + "END:VEVENT\r\n" + "BEGIN:VEVENT\r\n" + "UID:123\r\n" + "DTSTAMP:20210803T063522Z\r\n" + "DTSTART;VALUE=DATE:20210902\r\n" + "BEGIN:VALARM\r\n" + "ACTION:DISPLAY\r\n" + "TRIGGER:-PT15M\r\n" + "END:VALARM\r\n" + "DESCRIPTION:aaa \r\n" + "\r\n" + " aaa\\naaa 1\\n \r\n" + "SUMMARY:Summary\r\n" + "END:VEVENT\r\n" + "END:VCALENDAR\r\n"; + VObject *vcal; + + vcal = Parse_MIME(vcard1, (unsigned long)strlen(vcard1)); + if(vcal) { + icalcomponent *icalcomp; + + icalcomp = icalvcal_convert(vcal); + ok("vCard1 is not iCalendar", (icalcomp == NULL)); + if(icalcomp) + icalcomponent_free(icalcomp); + + cleanVObject (vcal); + } else { + ok("vCard1 cannot be parsed", (vcal == NULL)); + } + + vcal = Parse_MIME(vcard2, (unsigned long)strlen(vcard2)); + if(vcal) { + icalcomponent *icalcomp; + + icalcomp = icalvcal_convert(vcal); + ok("vCard2 is not iCalendar", (icalcomp == NULL)); + if(icalcomp) + icalcomponent_free(icalcomp); + + cleanVObject(vcal); + } else { + ok("vCard2 cannot be parsed", (vcal == NULL)); + } + + vcal = Parse_MIME(vcalendar, (unsigned long)strlen(vcalendar)); + ok("vCalendar can be parsed", (vcal != NULL)); + if(vcal) { + icalcomponent *icalcomp; + + icalcomp = icalvcal_convert(vcal); + ok("vCalendar can be converted", (icalcomp != NULL)); + if(icalcomp) { + icalcomponent *child; + + ok("vCalendar is VCALENDAR", (icalcomponent_isa(icalcomp) == ICAL_VCALENDAR_COMPONENT)); + ok("vCalendar has one child", (icalcomponent_count_components(icalcomp, ICAL_ANY_COMPONENT) == 1)); + child = icalcomponent_get_inner(icalcomp); + ok("vCalendar has inner comp", (child != NULL && child != icalcomp)); + ok("vCalendar child is VEVENT", (icalcomponent_isa(child) == ICAL_VEVENT_COMPONENT)); + ok("vCalendar child UID matches", (strcmp(icalcomponent_get_uid(child), "123") == 0)); + ok("vCalendar child SUMMARY matches", (strcmp(icalcomponent_get_summary(child), "Summary") == 0)); + icalcomponent_free(icalcomp); + } + + cleanVObject(vcal); + } + + vcal = Parse_MIME(vcalendar_broken, (unsigned long)strlen(vcalendar_broken)); + ok("vCalendar-broken cannot be parsed", (vcal == NULL)); +} + +static void test_implicit_dtend_duration(void) +{ + const struct icaltimetype start1 = icaltime_from_string("20220108"); + icalcomponent* c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VEVENT_COMPONENT, + icalproperty_vanew_dtstart(start1, 0), + 0), + 0); + struct icaldurationtype d = icalcomponent_get_duration(c); + struct icaltimetype end = icalcomponent_get_dtend(c), + start = icaltime_from_string("20220108T101010Z"); + if (VERBOSE) { + printf("%s\n", icaldurationtype_as_ical_string(d)); + } + str_is("icaldurationtype_as_ical_string(d)", "P1D", icaldurationtype_as_ical_string(d)); + + if (VERBOSE) { + printf("%s\n", icaltime_as_ical_string(end)); + } + str_is("icaltime_as_ical_string(end)", "20220109", icaltime_as_ical_string(end)); + + icalcomponent_set_dtstart(c, start); + d = icalcomponent_get_duration(c); + end = icalcomponent_get_dtend(c); + if (VERBOSE) { + printf("%s\n", icaldurationtype_as_ical_string(d)); + } + int_is("icaldurationtype_as_int(d)", 0, icaldurationtype_as_int(d)); + + if (VERBOSE) { + printf("%s\n", icaltime_as_ical_string(end)); + } + int_is("icaltime_compare(start, end)", 0, icaltime_compare(start, end)); + icalcomponent_free(c); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VTODO_COMPONENT, + icalproperty_vanew_dtstart(start1, 0), + 0), + 0); + icalcomponent_set_due(c, icaltime_from_string("20220109")); + d = icalcomponent_get_duration(c); + end = icalcomponent_get_dtend(c); + if (VERBOSE) { + printf("%s\n", icaldurationtype_as_ical_string(d)); + } + str_is("P1D", "P1D", icaldurationtype_as_ical_string(d)); + + if (VERBOSE) { + printf("%i\n", icaltime_is_null_time(end)); + } + int_is("icaltime_is_null_time(end)", 1, icaltime_is_null_time(end)); + icalcomponent_free(c); +} + +static void +test_icalvalue_resets_timezone_on_set(void) +{ + const char *strcomp = + "BEGIN:VCALENDAR\r\n" + "BEGIN:VTIMEZONE\r\n" + "TZID:my_zone\r\n" + "BEGIN:STANDARD\r\n" + "TZNAME:my_zone\r\n" + "DTSTART:19160429T230000\r\n" + "TZOFFSETFROM:+0100\r\n" + "TZOFFSETTO:+0200\r\n" + "RRULE:FREQ=YEARLY;UNTIL=19160430T220000Z;BYDAY=-1SU;BYMONTH=4\r\n" + "END:STANDARD\r\n" + "END:VTIMEZONE\r\n" + "BEGIN:VEVENT\r\n" + "UID:0\r\n" + "DTSTART;TZID=my_zone:20180101T010000\r\n" + "DTEND:20180202T020000Z\r\n" + "DUE:20180302T030000\r\n" + "END:VEVENT\r\n" + "END:VCALENDAR\r\n"; + icalcomponent *comp, *clone, *inner; + icaltimetype comp_dtstart, comp_dtend, comp_due; + icaltimetype clone_dtstart, clone_dtend, clone_due; + const char *orig_str, *clone_str; + int estate; + + estate = icalerror_get_errors_are_fatal(); + icalerror_set_errors_are_fatal(0); + + /* First try without calling 'set' */ + comp = icalcomponent_new_from_string(strcomp); + ok("1st - vCalendar can be parsed", (comp != NULL)); + inner = icalcomponent_get_inner(comp); + ok("1st - inner exists", (inner != NULL)); + orig_str = icalcomponent_as_ical_string(inner); + comp_dtstart = icalcomponent_get_dtstart(inner); + comp_dtend = icalcomponent_get_dtend(inner); + comp_due = icalcomponent_get_due(inner); + ok("1st - comp dtstart is non-UTC zone", (comp_dtstart.zone != NULL && comp_dtstart.zone != icaltimezone_get_utc_timezone())); + ok("1st - comp dtend is UTC zone", (comp_dtend.zone == icaltimezone_get_utc_timezone())); + ok("1st - comp due is floating", (comp_due.zone == NULL)); + clone = icalcomponent_new_clone(inner); + icalcomponent_free(comp); + /* note the comp_dtstart.zone points to a freed memory now (it was freed with the 'comp') */ + clone_dtstart = icalcomponent_get_dtstart(clone); + clone_dtend = icalcomponent_get_dtend(clone); + clone_due = icalcomponent_get_due(clone); + ok("1st - clone dtstart is null zone", (clone_dtstart.zone == NULL)); + ok("1st - clone dtend is UTC zone", (clone_dtend.zone == icaltimezone_get_utc_timezone())); + ok("1st - clone due is floating", (clone_due.zone == NULL)); + clone_str = icalcomponent_as_ical_string(clone); + ok("1st - clone and orig components match", (strcmp(orig_str, clone_str) == 0)); + icalcomponent_free(clone); + + /* Second try with calling 'set' */ + comp = icalcomponent_new_from_string(strcomp); + inner = icalcomponent_get_inner(comp); + orig_str = icalcomponent_as_ical_string(inner); + comp_dtstart = icalcomponent_get_dtstart(inner); + comp_dtend = icalcomponent_get_dtend(inner); + comp_due = icalcomponent_get_due(inner); + ok("2nd - comp dtstart is non-UTC zone", (comp_dtstart.zone != NULL && comp_dtstart.zone != icaltimezone_get_utc_timezone())); + ok("2nd - comp dtend is UTC zone", (comp_dtend.zone == icaltimezone_get_utc_timezone())); + ok("2nd - comp due is floating", (comp_due.zone == NULL)); + icalcomponent_set_dtstart(inner, comp_dtstart); + icalcomponent_set_dtend(inner, comp_dtend); + icalcomponent_set_due(inner, comp_due); + comp_dtstart = icalcomponent_get_dtstart(inner); + comp_dtend = icalcomponent_get_dtend(inner); + comp_due = icalcomponent_get_due(inner); + ok("2nd - comp dtstart is non-UTC zone", (comp_dtstart.zone != NULL && comp_dtstart.zone != icaltimezone_get_utc_timezone())); + ok("2nd - comp dtend is UTC zone after set", (comp_dtend.zone == icaltimezone_get_utc_timezone())); + ok("2nd - comp due is floating after set", (comp_due.zone == NULL)); + clone = icalcomponent_new_clone(inner); + icalcomponent_free(comp); + /* note the comp_dtstart.zone points to a freed memory now (it was freed with the 'comp') */ + clone_dtstart = icalcomponent_get_dtstart(clone); + clone_dtend = icalcomponent_get_dtend(clone); + clone_due = icalcomponent_get_due(clone); + ok("2nd - clone dtstart is null zone", (clone_dtstart.zone == NULL)); + ok("2nd - clone dtend is UTC zone", (clone_dtend.zone == icaltimezone_get_utc_timezone())); + ok("2nd - clone due is floating", (clone_due.zone == NULL)); + clone_str = icalcomponent_as_ical_string(clone); + ok("2nd - clone and orig components match", (strcmp(orig_str, clone_str) == 0)); + icalcomponent_free(clone); + + icalerror_set_errors_are_fatal(estate); + icalerror_clear_errno(); +} + +static void test_remove_tzid_from_due(void) +{ + icalproperty *due = icalproperty_vanew_due(icaltime_from_string("20220120T120000"), 0); + icalcomponent *c; + + icalproperty_add_parameter(due, icalparameter_new_tzid("America/New_York")); + + c = icalcomponent_vanew( + ICAL_VCALENDAR_COMPONENT, + icalcomponent_vanew( + ICAL_VTODO_COMPONENT, + due, + 0), + 0); + + icalcomponent_set_due(c, icaltime_from_string("20220120")); + str_is("icalproperty_as_ical_string()", "DUE;VALUE=DATE:20220120\r\n", icalproperty_as_ical_string(icalcomponent_get_first_property(icalcomponent_get_inner(c), ICAL_DUE_PROPERTY))); + + icalcomponent_free(c); +} + int main(int argc, char *argv[]) { #if !defined(HAVE_UNISTD_H) @@ -4892,6 +5237,17 @@ int main(int argc, char *argv[]) int do_header = 0; int failed_count = 0; +#if !defined(MEMORY_CONSISTENCY) + // With MEMORY_CONSISTENCY we are building the entire library using the + // test_* functions; therefore, no need to set them here again. + + // We specify special versions of malloc et al. that perform some extra verifications. + // Most notably they ensure, that memory allocated with icalmemory_new_buffer() is freed + // using icalmemory_free() rather than using free() directly and vice versa. Failing to + // do so would cause the test to fail with assertions or access violations. + icalmemory_set_mem_alloc_funcs(&test_malloc, &test_realloc, &test_free); +#endif + set_zone_directory(TEST_ZONEDIR); icaltimezone_set_tzid_prefix(TESTS_TZID_PREFIX); @@ -5021,6 +5377,11 @@ int main(int argc, char *argv[]) test_run("Test icalcomponent_normalize", test_icalcomponent_normalize, do_test, do_header); test_run("Test builtin compat TZID", test_builtin_compat_tzid, do_test, do_header); + test_run("Test VCC vCard parse", test_vcc_vcard_parse, do_test, do_header); + test_run("Test implicit DTEND and DURATION for VEVENT and VTODO", test_implicit_dtend_duration, do_test, do_header); + test_run("Test icalvalue resets timezone on set", test_icalvalue_resets_timezone_on_set, do_test, do_header); + test_run("Test removing TZID from DUE with icalcomponent_set_due", test_remove_tzid_from_due, do_test, do_header); + test_run("Test geo precision", test_geo_props, do_test, do_header); /** OPTIONAL TESTS go here... **/ diff --git a/src/test/regression.h b/src/test/regression.h index 9c5aab88..55531793 100644 --- a/src/test/regression.h +++ b/src/test/regression.h @@ -2,18 +2,10 @@ FILE: regression.c CREATOR: eric 03 April 1999 - (C) COPYRIGHT 1999 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 1999 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ ======================================================================*/ #ifndef TEST_REGRESSION_H #define TEST_REGRESSION_H @@ -52,7 +44,7 @@ extern "C" void test_bdbset(void); /* regression-utils.c */ - const char *ical_timet_string(const time_t t); + const char *ical_timet_string(const icaltime_t t); const char *ictt_as_string(struct icaltimetype t); char *icaltime_as_ctime(struct icaltimetype t); diff --git a/src/test/stow.c b/src/test/stow.c index 0b98126e..00b07d11 100644 --- a/src/test/stow.c +++ b/src/test/stow.c @@ -2,18 +2,9 @@ FILE: stow.c CREATOR: eric 29 April 2000 - (C) COPYRIGHT 2000 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ diff --git a/src/test/test-malloc.c b/src/test/test-malloc.c new file mode 100644 index 00000000..d9c46995 --- /dev/null +++ b/src/test/test-malloc.c @@ -0,0 +1,178 @@ +/*====================================================================== +FILE: test-malloc.c + +SPDX-FileCopyrightText: 2018-2022, Markus Minichmayr <markus@tapkey.com> + + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + +======================================================================*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "test-malloc.h" +#include "icalerror.h" +#if !defined(MEMORY_CONSISTENCY) +#include "regression.h" +#endif + +#include <stdlib.h> +#include <string.h> + +struct testmalloc_statistics global_testmalloc_statistics; +static int global_testmalloc_remaining_attempts = -1; + +#define TESTMALLOC_MAGIC_NO 0x1234abcd +struct testmalloc_hdr { + uint32_t magic_no; + size_t size; +}; + +struct testmalloc_hdrlayout { + struct testmalloc_hdr hdr; + int data; +}; + +#define TESTMALLOC_HDR_SIZE ((size_t) &((struct testmalloc_hdrlayout*) 0)->data) + +void *test_malloc(size_t size) { + + void *block; + struct testmalloc_hdr *hdr; + + global_testmalloc_statistics.malloc_cnt++; + if (global_testmalloc_remaining_attempts == 0) { + global_testmalloc_statistics.malloc_failed_cnt++; + return NULL; + } + + block = malloc(size + TESTMALLOC_HDR_SIZE); + if (block == NULL) { + global_testmalloc_statistics.malloc_failed_cnt++; + return NULL; + } + + hdr = (struct testmalloc_hdr *)block; + hdr->magic_no = TESTMALLOC_MAGIC_NO; + hdr->size = size; + + global_testmalloc_statistics.mem_allocated_current += size; + if (global_testmalloc_statistics.mem_allocated_current > global_testmalloc_statistics.mem_allocated_max) { + global_testmalloc_statistics.mem_allocated_max = global_testmalloc_statistics.mem_allocated_current; + } + + global_testmalloc_statistics.blocks_allocated++; + + if (global_testmalloc_remaining_attempts > 0) { + global_testmalloc_remaining_attempts--; + } + + return (void*) &((struct testmalloc_hdrlayout *) hdr)->data; +} + +void *test_realloc(void *p, size_t size) { + + struct testmalloc_hdr *hdr; + size_t old_size; + + global_testmalloc_statistics.realloc_cnt++; + if (global_testmalloc_remaining_attempts == 0) { + global_testmalloc_statistics.realloc_failed_cnt++; + return NULL; + } + + if (p == NULL) { + global_testmalloc_statistics.realloc_failed_cnt++; + return NULL; + } + + hdr = (struct testmalloc_hdr *) (((uint8_t *) p) - TESTMALLOC_HDR_SIZE); + if (hdr->magic_no != TESTMALLOC_MAGIC_NO) { + global_testmalloc_statistics.realloc_failed_cnt++; + return NULL; + } + + old_size = hdr->size; + hdr->magic_no = 0; + + // cppcheck-suppress memleakOnRealloc; the mem block p passed to this function stays valid. + hdr = (struct testmalloc_hdr *)realloc(hdr, size + TESTMALLOC_HDR_SIZE); + if (hdr == NULL) { + global_testmalloc_statistics.realloc_failed_cnt++; + return NULL; + } + + hdr->magic_no = TESTMALLOC_MAGIC_NO; + hdr->size = size; + + global_testmalloc_statistics.mem_allocated_current += size - old_size; + if (global_testmalloc_statistics.mem_allocated_current > global_testmalloc_statistics.mem_allocated_max) { + global_testmalloc_statistics.mem_allocated_max = global_testmalloc_statistics.mem_allocated_current; + } + + if (global_testmalloc_remaining_attempts > 0) { + global_testmalloc_remaining_attempts--; + } + + return (void *) &((struct testmalloc_hdrlayout *)hdr)->data; +} + +void test_free(void *p) { + + struct testmalloc_hdr *hdr; + size_t old_size; + + if (p == NULL) { + return; + } + + global_testmalloc_statistics.free_cnt++; + + hdr = (struct testmalloc_hdr *) (((uint8_t *) p) - TESTMALLOC_HDR_SIZE); + + // The main objective of this check is to ensure, that only memory, that has been allocated via icalmemory is freed + // via icalmemory_free(). A side objective is to make sure, the block of memory hasn't been corrupted. + if (hdr->magic_no != TESTMALLOC_MAGIC_NO) { + + // If we end up here, then probably either of the following happened: + // * The calling code tries to free a block of memory via icalmemory_free() that has been allocated outside of + // icalmemory, e.g. via malloc(). + // * The header in front of the memory block being freed has been corrupted. + +#if !defined(MEMORY_CONSISTENCY) + ok("freed memory was allocated via icalmemory and has not been corrupted", + hdr->magic_no == TESTMALLOC_MAGIC_NO); +#endif + icalerror_assert(hdr->magic_no == TESTMALLOC_MAGIC_NO, + "freed memory was allocated via icalmemory and has been corrupted"); + global_testmalloc_statistics.free_failed_cnt++; + return; + } + + old_size = hdr->size; + hdr->magic_no = 0; + + free(hdr); + + global_testmalloc_statistics.mem_allocated_current -= old_size; + global_testmalloc_statistics.blocks_allocated--; +} + +void testmalloc_reset() { + memset(&global_testmalloc_statistics, 0, sizeof(global_testmalloc_statistics)); + global_testmalloc_remaining_attempts = -1; +} + +/** Sets the maximum number of malloc or realloc attemts that will succeed. If +* the number is negative, no limit will be applied. */ +void testmalloc_set_max_successful_allocs(int n) { + global_testmalloc_remaining_attempts = n; +} + +void testmalloc_get_statistics(struct testmalloc_statistics *statistics) { + + if (statistics) { + *statistics = global_testmalloc_statistics; + } +} diff --git a/src/test/test-malloc.h b/src/test/test-malloc.h new file mode 100644 index 00000000..04858bae --- /dev/null +++ b/src/test/test-malloc.h @@ -0,0 +1,61 @@ +/*====================================================================== +FILE: test-malloc.h + +SPDX-FileCopyrightText: 2018-2022, Markus Minichmayr <markus@tapkey.com> + + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 + +======================================================================*/ + +#ifndef TESTMALLOC_H +#define TESTMALLOC_H + +#include <stdint.h> + +#include "libical_ical_export.h" + +struct testmalloc_statistics { + int malloc_cnt; + int realloc_cnt; + int free_cnt; + + int malloc_failed_cnt; + int realloc_failed_cnt; + int free_failed_cnt; + + size_t mem_allocated_max; + size_t mem_allocated_current; + int blocks_allocated; +}; + +/** Allocates the specified amount of memory and returns a pointer to the allocated memory. + * Memory allocated using this function must be freed using test_free(). + * The number of allocations that can be made using this function can be limited via + * testmalloc_set_max_successful_allocs(). + */ +LIBICAL_ICAL_EXPORT void *test_malloc(size_t size); + +/** Resizes the specified buffer. + * Can only be used with memory that has previously been allocated using test_malloc(). + */ +LIBICAL_ICAL_EXPORT void *test_realloc(void *p, size_t size); + +/** Frees a block of memory that has previously been allocated via the test_malloc() function. Specifying memory that + * has not been allocated via test_malloc() causes an assertion. + */ +LIBICAL_ICAL_EXPORT void test_free(void *p); + +/** Resets the memory management statistics and sets the number of successful + * allocations limit to infinite. + */ +LIBICAL_ICAL_EXPORT void testmalloc_reset(); + +/** Sets the maximum number of malloc or realloc attemts that will succeed. If + * the number is negative, no limit will be applied. + */ +LIBICAL_ICAL_EXPORT void testmalloc_set_max_successful_allocs(int n); + +/** Gets current memory allocation statistics. */ +LIBICAL_ICAL_EXPORT void testmalloc_get_statistics(struct testmalloc_statistics *statistics); + +#endif /* !TESTMALLOC_H */ diff --git a/src/test/testmime.c b/src/test/testmime.c index e0c53ea9..df904868 100644 --- a/src/test/testmime.c +++ b/src/test/testmime.c @@ -2,18 +2,9 @@ FILE: CREATOR: eric 25 June 2000 - (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Initial Developer of the Original Code is Eric Busboom ======================================================================*/ diff --git a/src/test/testvcal.c b/src/test/testvcal.c index 96650f44..f38df8a8 100644 --- a/src/test/testvcal.c +++ b/src/test/testvcal.c @@ -2,18 +2,9 @@ FILE: testvcal.c CREATOR: eric 26 May 2000 - (C) COPYRIGHT 2000 Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2000 Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 The Original Code is eric. The Initial Developer of the Original Code is Eric Busboom diff --git a/src/test/timezones.c b/src/test/timezones.c index 935e912d..0285e3b5 100644 --- a/src/test/timezones.c +++ b/src/test/timezones.c @@ -1,18 +1,9 @@ /* ====================================================================== - (C) COPYRIGHT 2008, Eric Busboom <eric@civicknowledge.com> + SPDX-FileCopyrightText: 2008, Eric Busboom <eric@civicknowledge.com> - This library is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html - - Or: - - The Mozilla Public License Version 2.0. You may obtain a copy of - the License at https://www.mozilla.org/MPL/ + SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 ======================================================================*/ @@ -39,9 +30,9 @@ int main() int verbose = 0; int day; - time_t start_time; + icaltime_t start_time; struct tm start_tm; - time_t curr_time; + icaltime_t curr_time; struct tm curr_tm; struct icaltimetype curr_tt; int failed = 0; @@ -82,19 +73,19 @@ int main() * determine current local time and date: always use midday in * the current zone and first day of first month in the year */ - start_time = time(NULL); - (void)localtime_r(&start_time, &start_tm); + start_time = icaltime(NULL); + (void)icallocaltime_r(&start_time, &start_tm); start_tm.tm_hour = 12; start_tm.tm_min = 0; start_tm.tm_sec = 0; start_tm.tm_mday = 1; start_tm.tm_mon = 0; - start_time = mktime(&start_tm); + start_time = icalmktime(&start_tm); /* check time conversion for the next 365 days */ for (day = 0, curr_time = start_time; day < 365; day++, curr_time += 24 * 60 * 60) { /* determine date/time with glibc */ - localtime_r(&curr_time, &curr_tm); + icallocaltime_r(&curr_time, &curr_tm); /* determine date/time with libical */ curr_tt = icaltime_from_timet_with_zone(curr_time, 0, utc_zone); curr_tt.zone = utc_zone; /* workaround: icaltime_from_timet_with_zone() @@ -114,7 +105,7 @@ int main() if (verbose || curr_failed != failed) { struct tm utc_tm; - if (!gmtime_r(&curr_time, &utc_tm)) + if (!icalgmtime_r(&curr_time, &utc_tm)) memset(&utc_tm, 0, sizeof(utc_tm)); printf( |