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 | |||
@@ -34,10 +34,11 @@ | |||
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; |
@@ -70,18 +71,25 @@ struct { | |||
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++) { |
@@ -93,7 +101,26 @@ const char* icalenum_reqstat_desc(icalrequeststatus stat) | |||
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; |
@@ -106,6 +133,8 @@ short icalenum_reqstat_major(icalrequeststatus stat) | |||
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; |
@@ -119,6 +148,8 @@ short icalenum_reqstat_minor(icalrequeststatus stat) | |||
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; |