2 /*======================================================================
4 CREATOR: eric 29 April 1999
6 $Id: icalenums.c,v 1.16 2008-01-15 23:17:40 dothebart Exp $
9 (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
10 http://www.softwarestudio.org
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
23 The original code is icalenum.c
25 ======================================================================*/
32 #include "icalenums.h"
34 #include <stdio.h> /* For fprintf */
35 #include <stdio.h> /* For stderr */
36 #include <string.h> /* For strncmp */
38 #include "icalmemory.h"
41 #define snprintf _snprintf
44 /*** @brief Allowed request status values
47 enum icalrequeststatus kind;
51 } request_status_map[] = {
52 {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."},
53 {ICAL_2_1_FALLBACK_STATUS, 2,1,"Success but fallback taken on one or more property values."},
54 {ICAL_2_2_IGPROP_STATUS, 2,2,"Success, invalid property ignored."},
55 {ICAL_2_3_IGPARAM_STATUS, 2,3,"Success, invalid property parameter ignored."},
56 {ICAL_2_4_IGXPROP_STATUS, 2,4,"Success, unknown non-standard property ignored."},
57 {ICAL_2_5_IGXPARAM_STATUS, 2,5,"Success, unknown non standard property value ignored."},
58 {ICAL_2_6_IGCOMP_STATUS, 2,6,"Success, invalid calendar component ignored."},
59 {ICAL_2_7_FORWARD_STATUS, 2,7,"Success, request forwarded to Calendar User."},
60 {ICAL_2_8_ONEEVENT_STATUS, 2,8,"Success, repeating event ignored. Scheduled as a single component."},
61 {ICAL_2_9_TRUNC_STATUS, 2,9,"Success, truncated end date time to date boundary."},
62 {ICAL_2_10_ONETODO_STATUS, 2,10,"Success, repeating VTODO ignored. Scheduled as a single VTODO."},
63 {ICAL_2_11_TRUNCRRULE_STATUS, 2,11,"Success, unbounded RRULE clipped at some finite number of instances "},
64 {ICAL_3_0_INVPROPNAME_STATUS, 3,0,"Invalid property name."},
65 {ICAL_3_1_INVPROPVAL_STATUS, 3,1,"Invalid property value."},
66 {ICAL_3_2_INVPARAM_STATUS, 3,2,"Invalid property parameter."},
67 {ICAL_3_3_INVPARAMVAL_STATUS, 3,3,"Invalid property parameter value."},
68 {ICAL_3_4_INVCOMP_STATUS, 3,4,"Invalid calendar component."},
69 {ICAL_3_5_INVTIME_STATUS, 3,5,"Invalid date or time."},
70 {ICAL_3_6_INVRULE_STATUS, 3,6,"Invalid rule."},
71 {ICAL_3_7_INVCU_STATUS, 3,7,"Invalid Calendar User."},
72 {ICAL_3_8_NOAUTH_STATUS, 3,8,"No authority."},
73 {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."},
74 {ICAL_3_10_TOOBIG_STATUS, 3,10,"Request entity too large."},
75 {ICAL_3_11_MISSREQCOMP_STATUS, 3,11,"Required component or property missing."},
76 {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."},
77 {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"},
78 {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."},
79 {ICAL_3_15_INVCOMMAND, 3,15,"Invalid command."},
80 {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."},
81 {ICAL_4_1_STORE_ACCESS_DENIED, 4,1,"Store Access Denied."},
82 {ICAL_4_2_STORE_FAILED, 4,2,"Store Failed."},
83 {ICAL_4_3_STORE_NOT_FOUND, 4,3,"Store not found."},
84 {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."},
85 {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."},
86 {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."},
87 {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."},
88 {ICAL_6_1_CONTAINER_NOT_FOUND, 6,1,"Container not found."},
89 {ICAL_9_0_UNRECOGNIZED_COMMAND, 9,0,"An unrecognized command was received."},
90 {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"}
94 /*** @brief Return the descriptive text for a request status
96 const char* icalenum_reqstat_desc(icalrequeststatus stat)
100 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
101 if ( request_status_map[i].kind == stat) {
102 return request_status_map[i].str;
109 char* icalenum_reqstat_code(icalrequeststatus stat)
112 buf = icalenum_reqstat_code_r(stat);
113 icalmemory_add_tmp_buffer(buf);
118 /*** @brief Return the code for a request status
120 char* icalenum_reqstat_code_r(icalrequeststatus stat)
125 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
126 if ( request_status_map[i].kind == stat) {
127 major = request_status_map[i].major;
128 minor = request_status_map[i].minor;
129 snprintf(tmpbuf, sizeof(tmpbuf), "%i.%i", major, minor);
130 return icalmemory_strdup(tmpbuf);
136 /*** @brief Return the major number for a request status
138 short icalenum_reqstat_major(icalrequeststatus stat)
142 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
143 if ( request_status_map[i].kind == stat) {
144 return request_status_map[i].major;
150 /*** @brief Return the minor number for a request status
152 short icalenum_reqstat_minor(icalrequeststatus stat)
156 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
157 if ( request_status_map[i].kind == stat) {
158 return request_status_map[i].minor;
165 /*** @brief Return a request status for major/minor status numbers
167 icalrequeststatus icalenum_num_to_reqstat(short major, short minor)
171 for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) {
172 if ( request_status_map[i].major == major && request_status_map[i].minor == minor) {
173 return request_status_map[i].kind;