summaryrefslogtreecommitdiff
path: root/src/libical
diff options
context:
space:
mode:
Diffstat (limited to 'src/libical')
-rw-r--r--src/libical/CMakeLists.txt35
-rw-r--r--src/libical/astime.h13
-rw-r--r--src/libical/caldate.c20
-rw-r--r--src/libical/ical_file.cmake5
-rw-r--r--src/libical/icalarray.c50
-rw-r--r--src/libical/icalarray.h46
-rw-r--r--src/libical/icalattach.c31
-rw-r--r--src/libical/icalattach.h56
-rw-r--r--src/libical/icalattachimpl.h12
-rw-r--r--src/libical/icalcomponent.c233
-rw-r--r--src/libical/icalcomponent.h42
-rw-r--r--src/libical/icalderivedparameter.c.in13
-rw-r--r--src/libical/icalderivedparameter.h.in13
-rw-r--r--src/libical/icalderivedproperty.c.in12
-rw-r--r--src/libical/icalderivedproperty.h.in13
-rw-r--r--src/libical/icalderivedvalue.c.in33
-rw-r--r--src/libical/icalderivedvalue.h.in12
-rw-r--r--src/libical/icalduration.c17
-rw-r--r--src/libical/icalduration.h49
-rw-r--r--src/libical/icalenums.c27
-rw-r--r--src/libical/icalenums.h19
-rw-r--r--src/libical/icalerror.c28
-rw-r--r--src/libical/icalerror.h65
-rw-r--r--src/libical/icallangbind.c26
-rw-r--r--src/libical/icallangbind.h12
-rw-r--r--src/libical/icalmemory.c155
-rw-r--r--src/libical/icalmemory.h105
-rw-r--r--src/libical/icalmime.c38
-rw-r--r--src/libical/icalmime.h12
-rw-r--r--src/libical/icalparameter.c35
-rw-r--r--src/libical/icalparameter.h134
-rw-r--r--src/libical/icalparameter_cxx.cpp12
-rw-r--r--src/libical/icalparameter_cxx.h12
-rw-r--r--src/libical/icalparameterimpl.h13
-rw-r--r--src/libical/icalparser.c47
-rw-r--r--src/libical/icalparser.h65
-rw-r--r--src/libical/icalperiod.c13
-rw-r--r--src/libical/icalperiod.h27
-rw-r--r--src/libical/icalproperty.c41
-rw-r--r--src/libical/icalproperty.h14
-rw-r--r--src/libical/icalproperty_cxx.cpp12
-rw-r--r--src/libical/icalproperty_cxx.h12
-rw-r--r--src/libical/icalproperty_p.h12
-rw-r--r--src/libical/icalrecur.c63
-rw-r--r--src/libical/icalrecur.h18
-rw-r--r--src/libical/icalrestriction.c.in661
-rw-r--r--src/libical/icalrestriction.h19
-rw-r--r--src/libical/icaltime.c67
-rw-r--r--src/libical/icaltime.h.cmake (renamed from src/libical/icaltime.h)32
-rw-r--r--src/libical/icaltimezone.c98
-rw-r--r--src/libical/icaltimezone.h12
-rw-r--r--src/libical/icaltimezoneimpl.h12
-rw-r--r--src/libical/icaltypes.c12
-rw-r--r--src/libical/icaltypes.h17
-rw-r--r--src/libical/icaltz-util.c72
-rw-r--r--src/libical/icaltz-util.h17
-rw-r--r--src/libical/icalvalue.c99
-rw-r--r--src/libical/icalvalue.h12
-rw-r--r--src/libical/icalvalue_cxx.cpp12
-rw-r--r--src/libical/icalvalue_cxx.h12
-rw-r--r--src/libical/icalvalueimpl.h13
-rw-r--r--src/libical/icalversion.h.cmake12
-rw-r--r--src/libical/icptrholder_cxx.h16
-rw-r--r--src/libical/libical_deprecated.h5
-rw-r--r--src/libical/libical_ical_export.h5
-rw-r--r--src/libical/pvl.c24
-rw-r--r--src/libical/pvl.h12
-rw-r--r--src/libical/qsort_gen.c11
-rw-r--r--src/libical/qsort_gen.h14
-rw-r--r--src/libical/sspm.c114
-rw-r--r--src/libical/sspm.h26
-rw-r--r--src/libical/vcomponent_cxx.cpp12
-rw-r--r--src/libical/vcomponent_cxx.h12
73 files changed, 1536 insertions, 1616 deletions
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