$darkmode
Libical API Documentation 4.0 STABLE VERSION Visit the v3.0 documentation
icalenums.c
Go to the documentation of this file.
1 /*======================================================================
2  FILE: icalenums.c
3  CREATOR: eric 29 April 1999
4 
5  SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6  SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
7 ======================================================================*/
8 
14 #ifdef HAVE_CONFIG_H
15 #include <config.h>
16 #endif
17 
18 #include "icalenums.h"
19 #include "icalmemory.h"
20 
24 static const struct
25 {
26  enum icalrequeststatus kind;
27  int major;
28  int minor;
29  const char *str;
30 } request_status_map[] = {
31  {ICAL_2_0_SUCCESS_STATUS, 2, 0, "Success."},
33  "Success but fallback taken on one or more property values."},
34  {ICAL_2_2_IGPROP_STATUS, 2, 2, "Success, invalid property ignored."},
35  {ICAL_2_3_IGPARAM_STATUS, 2, 3, "Success, invalid property parameter ignored."},
36  {ICAL_2_4_IGXPROP_STATUS, 2, 4, "Success, unknown non-standard property ignored."},
37  {ICAL_2_5_IGXPARAM_STATUS, 2, 5, "Success, unknown non standard property value ignored."},
38  {ICAL_2_6_IGCOMP_STATUS, 2, 6, "Success, invalid calendar component ignored."},
39  {ICAL_2_7_FORWARD_STATUS, 2, 7, "Success, request forwarded to Calendar User."},
41  "Success, repeating event ignored. Scheduled as a single component."},
42  {ICAL_2_9_TRUNC_STATUS, 2, 9, "Success, truncated end date time to date boundary."},
44  "Success, repeating VTODO ignored. Scheduled as a single VTODO."},
46  "Success, unbounded RRULE clipped at some finite number of instances."},
47  {ICAL_3_0_INVPROPNAME_STATUS, 3, 0, "Invalid property name."},
48  {ICAL_3_1_INVPROPVAL_STATUS, 3, 1, "Invalid property value."},
49  {ICAL_3_2_INVPARAM_STATUS, 3, 2, "Invalid property parameter."},
50  {ICAL_3_3_INVPARAMVAL_STATUS, 3, 3, "Invalid property parameter value."},
51  {ICAL_3_4_INVCOMP_STATUS, 3, 4, "Invalid calendar component."},
52  {ICAL_3_5_INVTIME_STATUS, 3, 5, "Invalid date or time."},
53  {ICAL_3_6_INVRULE_STATUS, 3, 6, "Invalid rule."},
54  {ICAL_3_7_INVCU_STATUS, 3, 7, "Invalid Calendar User."},
55  {ICAL_3_8_NOAUTH_STATUS, 3, 8, "No authority."},
56  {ICAL_3_9_BADVERSION_STATUS, 3, 9, "Unsupported version."},
57  {ICAL_3_10_TOOBIG_STATUS, 3, 10, "Request entity too large."},
58  {ICAL_3_11_MISSREQCOMP_STATUS, 3, 11, "Required component or property missing."},
59  {ICAL_3_12_UNKCOMP_STATUS, 3, 12, "Unknown component or property found."},
60  {ICAL_3_13_BADCOMP_STATUS, 3, 13, "Unsupported component or property found."},
61  {ICAL_3_14_NOCAP_STATUS, 3, 14, "Unsupported capability."},
62  {ICAL_3_15_INVCOMMAND, 3, 15, "Invalid command."},
63  {ICAL_4_0_BUSY_STATUS, 4, 0, "Event conflict. Date/time is busy."},
64  {ICAL_4_1_STORE_ACCESS_DENIED, 4, 1, "Store Access Denied."},
65  {ICAL_4_2_STORE_FAILED, 4, 2, "Store Failed."},
66  {ICAL_4_3_STORE_NOT_FOUND, 4, 3, "Store not found."},
67  {ICAL_5_0_MAYBE_STATUS, 5, 0, "Request MAY supported."},
68  {ICAL_5_1_UNAVAIL_STATUS, 5, 1, "Service unavailable."},
69  {ICAL_5_2_NOSERVICE_STATUS, 5, 2, "Invalid calendar service."},
70  {ICAL_5_3_NOSCHED_STATUS, 5, 3, "No scheduling support for user."},
71  {ICAL_6_1_CONTAINER_NOT_FOUND, 6, 1, "Container not found."},
72  {ICAL_9_0_UNRECOGNIZED_COMMAND, 9, 0, "An unrecognized command was received."},
73  {ICAL_UNKNOWN_STATUS, 0, 0, "Error: Unknown request status."}};
74 
76 {
77  int i;
78 
79  int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0]));
80  for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
81  if (request_status_map[i].kind == stat) {
82  return request_status_map[i].str;
83  }
84  }
85 
86  return 0;
87 }
88 
90 {
91  char *buf;
92 
93  buf = icalenum_reqstat_code_r(stat);
95  return buf;
96 }
97 
99 {
100  char tmpbuf[36];
101 
102  int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0]));
103  for (int i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
104  if (request_status_map[i].kind == stat) {
105  int major = request_status_map[i].major;
106  int minor = request_status_map[i].minor;
107  snprintf(tmpbuf, sizeof(tmpbuf), "%i.%i", major, minor);
108  return icalmemory_strdup(tmpbuf);
109  }
110  }
111  return NULL;
112 }
113 
115 {
116  int i;
117 
118  int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0]));
119  for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
120  if (request_status_map[i].kind == stat) {
121  return request_status_map[i].major;
122  }
123  }
124  return -1;
125 }
126 
128 {
129  int i;
130 
131  int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0]));
132  for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
133  if (request_status_map[i].kind == stat) {
134  return request_status_map[i].minor;
135  }
136  }
137  return -1;
138 }
139 
141 {
142  int i;
143 
144  int len = (int)(sizeof(request_status_map) / sizeof(request_status_map[0]));
145  for (i = 0; i < len && request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
146  if (request_status_map[i].major == major && request_status_map[i].minor == minor) {
147  return request_status_map[i].kind;
148  }
149  }
150  return 0;
151 }
Common memory management routines.
char * icalenum_reqstat_code(icalrequeststatus stat)
Definition: icalenums.c:89
short icalenum_reqstat_minor(icalrequeststatus stat)
Definition: icalenums.c:127
char * icalmemory_strdup(const char *s)
Creates a duplicate of a string.
Definition: icalmemory.c:242
char * icalenum_reqstat_code_r(icalrequeststatus stat)
Definition: icalenums.c:98
short icalenum_reqstat_major(icalrequeststatus stat)
Definition: icalenums.c:114
icalrequeststatus icalenum_num_to_reqstat(short major, short minor)
Definition: icalenums.c:140
const char * icalenum_reqstat_desc(icalrequeststatus stat)
Definition: icalenums.c:75
icalrequeststatus
Definition: icalenums.h:78
void icalmemory_add_tmp_buffer(void *buf)
Adds an externally allocated buffer to the ring.
Definition: icalmemory.c:158
Defines enums not belonging to other data structures.