Diffstat (limited to 'libical/src/libical/icalenums.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icalenums.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/libical/src/libical/icalenums.c b/libical/src/libical/icalenums.c new file mode 100644 index 0000000..6751933 --- a/dev/null +++ b/libical/src/libical/icalenums.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /* -*- Mode: C -*- */ | ||
2 | /*====================================================================== | ||
3 | FILE: icalenum.c | ||
4 | CREATOR: eric 29 April 1999 | ||
5 | |||
6 | $Id$ | ||
7 | |||
8 | |||
9 | (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org | ||
10 | |||
11 | This program is free software; you can redistribute it and/or modify | ||
12 | it under the terms of either: | ||
13 | |||
14 | The LGPL as published by the Free Software Foundation, version | ||
15 | 2.1, available at: http://www.fsf.org/copyleft/lesser.html | ||
16 | |||
17 | Or: | ||
18 | |||
19 | The Mozilla Public License Version 1.0. You may obtain a copy of | ||
20 | the License at http://www.mozilla.org/MPL/ | ||
21 | |||
22 | The original code is icalenum.c | ||
23 | |||
24 | ======================================================================*/ | ||
25 | |||
26 | |||
27 | #ifdef HAVE_CONFIG_H | ||
28 | #include "config.h" | ||
29 | #endif | ||
30 | |||
31 | #include "icalenums.h" | ||
32 | |||
33 | #include <stdio.h> /* For fprintf */ | ||
34 | #include <stdio.h> /* For stderr */ | ||
35 | #include <string.h> /* For strncmp */ | ||
36 | #include <assert.h> | ||
37 | |||
38 | |||
39 | |||
40 | struct { | ||
41 | enum icalrequeststatus kind; | ||
42 | int major; | ||
43 | int minor; | ||
44 | const char* str; | ||
45 | } request_status_map[] = { | ||
46 | {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."}, | ||
47 | {ICAL_2_1_FALLBACK_STATUS, 2,1,"Success but fallback taken on one or more property values."}, | ||
48 | {ICAL_2_2_IGPROP_STATUS, 2,2,"Success, invalid property ignored."}, | ||
49 | {ICAL_2_3_IGPARAM_STATUS, 2,3,"Success, invalid property parameter ignored."}, | ||
50 | {ICAL_2_4_IGXPROP_STATUS, 2,4,"Success, unknown non-standard property ignored."}, | ||
51 | {ICAL_2_5_IGXPARAM_STATUS, 2,5,"Success, unknown non standard property value ignored."}, | ||
52 | {ICAL_2_6_IGCOMP_STATUS, 2,6,"Success, invalid calendar component ignored."}, | ||
53 | {ICAL_2_7_FORWARD_STATUS, 2,7,"Success, request forwarded to Calendar User."}, | ||
54 | {ICAL_2_8_ONEEVENT_STATUS, 2,8,"Success, repeating event ignored. Scheduled as a single component."}, | ||
55 | {ICAL_2_9_TRUNC_STATUS, 2,9,"Success, truncated end date time to date boundary."}, | ||
56 | {ICAL_2_10_ONETODO_STATUS, 2,10,"Success, repeating VTODO ignored. Scheduled as a single VTODO."}, | ||
57 | {ICAL_2_11_TRUNCRRULE_STATUS, 2,11,"Success, unbounded RRULE clipped at some finite number of instances "}, | ||
58 | {ICAL_3_0_INVPROPNAME_STATUS, 3,0,"Invalid property name."}, | ||
59 | {ICAL_3_1_INVPROPVAL_STATUS, 3,1,"Invalid property value."}, | ||
60 | {ICAL_3_2_INVPARAM_STATUS, 3,2,"Invalid property parameter."}, | ||
61 | {ICAL_3_3_INVPARAMVAL_STATUS, 3,3,"Invalid property parameter value."}, | ||
62 | {ICAL_3_4_INVCOMP_STATUS, 3,4,"Invalid calendar component."}, | ||
63 | {ICAL_3_5_INVTIME_STATUS, 3,5,"Invalid date or time."}, | ||
64 | {ICAL_3_6_INVRULE_STATUS, 3,6,"Invalid rule."}, | ||
65 | {ICAL_3_7_INVCU_STATUS, 3,7,"Invalid Calendar User."}, | ||
66 | {ICAL_3_8_NOAUTH_STATUS, 3,8,"No authority."}, | ||
67 | {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."}, | ||
68 | {ICAL_3_10_TOOBIG_STATUS, 3,10,"Request entity too large."}, | ||
69 | {ICAL_3_11_MISSREQCOMP_STATUS, 3,11,"Required component or property missing."}, | ||
70 | {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."}, | ||
71 | {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"}, | ||
72 | {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."}, | ||
73 | {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."}, | ||
74 | {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."}, | ||
75 | {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."}, | ||
76 | {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."}, | ||
77 | {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."}, | ||
78 | {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"} | ||
79 | }; | ||
80 | |||
81 | |||
82 | const char* icalenum_reqstat_desc(icalrequeststatus stat) | ||
83 | { | ||
84 | |||
85 | int i; | ||
86 | |||
87 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | ||
88 | if ( request_status_map[i].kind == stat) { | ||
89 | return request_status_map[i].str; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | |||
97 | short icalenum_reqstat_major(icalrequeststatus stat) | ||
98 | { | ||
99 | int i; | ||
100 | |||
101 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | ||
102 | if ( request_status_map[i].kind == stat) { | ||
103 | return request_status_map[i].major; | ||
104 | } | ||
105 | } | ||
106 | return -1; | ||
107 | } | ||
108 | |||
109 | short icalenum_reqstat_minor(icalrequeststatus stat) | ||
110 | { | ||
111 | int i; | ||
112 | |||
113 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | ||
114 | if ( request_status_map[i].kind == stat) { | ||
115 | return request_status_map[i].minor; | ||
116 | } | ||
117 | } | ||
118 | return -1; | ||
119 | } | ||
120 | |||
121 | |||
122 | icalrequeststatus icalenum_num_to_reqstat(short major, short minor) | ||
123 | { | ||
124 | int i; | ||
125 | |||
126 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | ||
127 | if ( request_status_map[i].major == major && request_status_map[i].minor == minor) { | ||
128 | return request_status_map[i].kind; | ||
129 | } | ||
130 | } | ||
131 | return 0; | ||
132 | } | ||
133 | |||
134 | |||
135 | |||