1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*======================================================================
FILE: icalrestriction.h
CREATOR: eric 24 April 1999
(C) COPYRIGHT 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/
The original code is icalrestriction.h
Contributions from:
Graham Davison (g.m.davison@computer.org)
======================================================================*/
#ifndef ICALRESTRICTION_H
#define ICALRESTRICTION_H
/**
* @file icalrestriction.h
* @brief Functions to check if an icalcomponent meets the restrictions
* imposed by the standard.
*/
#include "libical_ical_export.h"
#include "icalcomponent.h"
#include "icalproperty.h"
/**
* @brief The kinds of icalrestrictions there are
*
* These must stay in this order for icalrestriction_compare to work
*/
typedef enum icalrestriction_kind
{
/** No restriction. */
ICAL_RESTRICTION_NONE = 0, /* 0 */
/** Zero. */
ICAL_RESTRICTION_ZERO, /* 1 */
/** One. */
ICAL_RESTRICTION_ONE, /* 2 */
/** Zero or more. */
ICAL_RESTRICTION_ZEROPLUS, /* 3 */
/** One or more. */
ICAL_RESTRICTION_ONEPLUS, /* 4 */
/** Zero or one. */
ICAL_RESTRICTION_ZEROORONE, /* 5 */
/** Zero or one, exclusive with another property. */
ICAL_RESTRICTION_ONEEXCLUSIVE, /* 6 */
/** Zero or one, mutual with another property. */
ICAL_RESTRICTION_ONEMUTUAL, /* 7 */
/** Unknown. */
ICAL_RESTRICTION_UNKNOWN /* 8 */
} icalrestriction_kind;
/**
* @brief Checks if the given @a count is in accordance with the given
* restriction, @a restr.
* @param restr The restriction to apply to the @a count
* @param count The amount present that is to be checked against the restriction
* @return 1 if the restriction is met, 0 if not
*
* @par Example
* ```c
* assert(icalrestriction_compare(ICALRESTRICTION_ONEPLUS, 5) == true);
* assert(icalrestriction_compare(ICALRESTRICTION_NONE, 3) == false);
* ```
*/
LIBICAL_ICAL_EXPORT int icalrestriction_compare(icalrestriction_kind restr, int count);
/**
* @brief Checks if a given `VCALENDAR` meets all the restrictions imposed by
* the standard.
* @param comp The `VCALENDAR` component to check
* @return 1 if the restrictions are met, 0 if not
*
* @par Error handling
* Returns 0 and sets ::icalerrno if `NULL` is passed as @a comp, or if the
* component is not a `VCALENDAR`.
*
* @par Example
* ```c
* icalcomponent *component = // ...
*
* // check component
* assert(icalrestriction_check(component) == true);
* ```
*/
LIBICAL_ICAL_EXPORT int icalrestriction_check(icalcomponent *comp);
#endif /* !ICALRESTRICTION_H */
|