Diffstat (limited to 'libical/src/libical/icalenums.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libical/icalenums.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/libical/src/libical/icalenums.c b/libical/src/libical/icalenums.c index 6751933..66c5ccd 100644 --- a/libical/src/libical/icalenums.c +++ b/libical/src/libical/icalenums.c | |||
@@ -31,16 +31,17 @@ | |||
31 | #include "icalenums.h" | 31 | #include "icalenums.h" |
32 | 32 | ||
33 | #include <stdio.h> /* For fprintf */ | 33 | #include <stdio.h> /* For fprintf */ |
34 | #include <stdio.h> /* For stderr */ | 34 | #include <stdio.h> /* For stderr */ |
35 | #include <string.h> /* For strncmp */ | 35 | #include <string.h> /* For strncmp */ |
36 | #include <assert.h> | 36 | #include <assert.h> |
37 | #include "icalmemory.h" | ||
37 | 38 | ||
38 | 39 | /*** @brief Allowed request status values | |
39 | 40 | */ | |
40 | struct { | 41 | static struct { |
41 | enum icalrequeststatus kind; | 42 | enum icalrequeststatus kind; |
42 | int major; | 43 | int major; |
43 | int minor; | 44 | int minor; |
44 | const char* str; | 45 | const char* str; |
45 | } request_status_map[] = { | 46 | } request_status_map[] = { |
46 | {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."}, | 47 | {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."}, |
@@ -67,48 +68,76 @@ struct { | |||
67 | {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."}, | 68 | {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."}, |
68 | {ICAL_3_10_TOOBIG_STATUS, 3,10,"Request entity too large."}, | 69 | {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_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_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_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"}, |
72 | {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."}, | 73 | {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."}, |
74 | {ICAL_3_15_INVCOMMAND, 3,15,"Invalid command."}, | ||
73 | {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."}, | 75 | {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."}, |
76 | {ICAL_4_1_STORE_ACCESS_DENIED, 4,1,"Store Access Denied."}, | ||
77 | {ICAL_4_2_STORE_FAILED, 4,2,"Store Failed."}, | ||
78 | {ICAL_4_3_STORE_NOT_FOUND, 4,3,"Store not found."}, | ||
74 | {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."}, | 79 | {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."}, |
75 | {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."}, | 80 | {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."}, |
76 | {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."}, | 81 | {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."}, |
77 | {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."}, | 82 | {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."}, |
83 | {ICAL_6_1_CONTAINER_NOT_FOUND, 6,1,"Container not found."}, | ||
84 | {ICAL_9_0_UNRECOGNIZED_COMMAND, 9,0,"An unrecognized command was received."}, | ||
78 | {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"} | 85 | {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"} |
79 | }; | 86 | }; |
80 | 87 | ||
81 | 88 | ||
89 | /*** @brief Return the descriptive text for a request status | ||
90 | */ | ||
82 | const char* icalenum_reqstat_desc(icalrequeststatus stat) | 91 | const char* icalenum_reqstat_desc(icalrequeststatus stat) |
83 | { | 92 | { |
84 | |||
85 | int i; | 93 | int i; |
86 | 94 | ||
87 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | 95 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { |
88 | if ( request_status_map[i].kind == stat) { | 96 | if ( request_status_map[i].kind == stat) { |
89 | return request_status_map[i].str; | 97 | return request_status_map[i].str; |
90 | } | 98 | } |
91 | } | 99 | } |
92 | 100 | ||
93 | return 0; | 101 | return 0; |
94 | } | 102 | } |
95 | 103 | ||
104 | /*** @brief Return the code for a request status | ||
105 | */ | ||
106 | char* icalenum_reqstat_code(icalrequeststatus stat) | ||
107 | { | ||
108 | int i, major, minor; | ||
109 | char tmpbuf[36]; | ||
110 | |||
111 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | ||
112 | if ( request_status_map[i].kind == stat) { | ||
113 | major = request_status_map[i].major; | ||
114 | minor = request_status_map[i].minor; | ||
115 | sprintf(tmpbuf, "%i.%i", major, minor); | ||
116 | return icalmemory_tmp_copy(tmpbuf); | ||
117 | } | ||
118 | } | ||
119 | return NULL; | ||
120 | } | ||
96 | 121 | ||
122 | /*** @brief Return the major number for a request status | ||
123 | */ | ||
97 | short icalenum_reqstat_major(icalrequeststatus stat) | 124 | short icalenum_reqstat_major(icalrequeststatus stat) |
98 | { | 125 | { |
99 | int i; | 126 | int i; |
100 | 127 | ||
101 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | 128 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { |
102 | if ( request_status_map[i].kind == stat) { | 129 | if ( request_status_map[i].kind == stat) { |
103 | return request_status_map[i].major; | 130 | return request_status_map[i].major; |
104 | } | 131 | } |
105 | } | 132 | } |
106 | return -1; | 133 | return -1; |
107 | } | 134 | } |
108 | 135 | ||
136 | /*** @brief Return the minor number for a request status | ||
137 | */ | ||
109 | short icalenum_reqstat_minor(icalrequeststatus stat) | 138 | short icalenum_reqstat_minor(icalrequeststatus stat) |
110 | { | 139 | { |
111 | int i; | 140 | int i; |
112 | 141 | ||
113 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | 142 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { |
114 | if ( request_status_map[i].kind == stat) { | 143 | if ( request_status_map[i].kind == stat) { |
@@ -116,12 +145,14 @@ short icalenum_reqstat_minor(icalrequeststatus stat) | |||
116 | } | 145 | } |
117 | } | 146 | } |
118 | return -1; | 147 | return -1; |
119 | } | 148 | } |
120 | 149 | ||
121 | 150 | ||
151 | /*** @brief Return a request status for major/minor status numbers | ||
152 | */ | ||
122 | icalrequeststatus icalenum_num_to_reqstat(short major, short minor) | 153 | icalrequeststatus icalenum_num_to_reqstat(short major, short minor) |
123 | { | 154 | { |
124 | int i; | 155 | int i; |
125 | 156 | ||
126 | for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { | 157 | 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) { | 158 | if ( request_status_map[i].major == major && request_status_map[i].minor == minor) { |