Back to index

lightning-sunbird  0.9+nobinonly
icalenums.c
Go to the documentation of this file.
00001 /* -*- Mode: C -*- */
00002 /*======================================================================
00003   FILE: icalenum.c
00004   CREATOR: eric 29 April 1999
00005   
00006   $Id: icalenums.c,v 1.13 2002/06/11 12:22:25 acampi Exp $
00007 
00008 
00009  (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
00010 
00011  This program is free software; you can redistribute it and/or modify
00012  it under the terms of either: 
00013 
00014     The LGPL as published by the Free Software Foundation, version
00015     2.1, available at: http://www.fsf.org/copyleft/lesser.html
00016 
00017   Or:
00018 
00019     The Mozilla Public License Version 1.0. You may obtain a copy of
00020     the License at http://www.mozilla.org/MPL/
00021 
00022   The original code is icalenum.c
00023 
00024   ======================================================================*/
00025 
00026 
00027 #ifdef HAVE_CONFIG_H
00028 #include "config.h"
00029 #endif
00030 
00031 #include "icalenums.h"
00032 
00033 #include <stdio.h> /* For fprintf */
00034 #include <stdio.h> /* For stderr */
00035 #include <string.h> /* For strncmp */
00036 #include <assert.h>
00037 #include "icalmemory.h"
00038 
00039 /*** @brief Allowed request status values
00040  */
00041 static struct {
00042         enum icalrequeststatus kind;
00043        int major;
00044        int minor;
00045        const char* str;
00046 } request_status_map[] = {
00047     {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."},
00048     {ICAL_2_1_FALLBACK_STATUS, 2,1,"Success but fallback taken  on one or more property  values."},
00049     {ICAL_2_2_IGPROP_STATUS, 2,2,"Success, invalid property ignored."},
00050     {ICAL_2_3_IGPARAM_STATUS, 2,3,"Success, invalid property parameter ignored."},
00051     {ICAL_2_4_IGXPROP_STATUS, 2,4,"Success, unknown non-standard property ignored."},
00052     {ICAL_2_5_IGXPARAM_STATUS, 2,5,"Success, unknown non standard property value  ignored."},
00053     {ICAL_2_6_IGCOMP_STATUS, 2,6,"Success, invalid calendar component ignored."},
00054     {ICAL_2_7_FORWARD_STATUS, 2,7,"Success, request forwarded to Calendar User."},
00055     {ICAL_2_8_ONEEVENT_STATUS, 2,8,"Success, repeating event ignored. Scheduled as a  single component."},
00056     {ICAL_2_9_TRUNC_STATUS, 2,9,"Success, truncated end date time to date boundary."},
00057     {ICAL_2_10_ONETODO_STATUS, 2,10,"Success, repeating VTODO ignored. Scheduled as a  single VTODO."},
00058     {ICAL_2_11_TRUNCRRULE_STATUS, 2,11,"Success, unbounded RRULE clipped at some finite  number of instances  "},
00059     {ICAL_3_0_INVPROPNAME_STATUS, 3,0,"Invalid property name."},
00060     {ICAL_3_1_INVPROPVAL_STATUS, 3,1,"Invalid property value."},
00061     {ICAL_3_2_INVPARAM_STATUS, 3,2,"Invalid property parameter."},
00062     {ICAL_3_3_INVPARAMVAL_STATUS, 3,3,"Invalid property parameter  value."},
00063     {ICAL_3_4_INVCOMP_STATUS, 3,4,"Invalid calendar component."},
00064     {ICAL_3_5_INVTIME_STATUS, 3,5,"Invalid date or time."},
00065     {ICAL_3_6_INVRULE_STATUS, 3,6,"Invalid rule."},
00066     {ICAL_3_7_INVCU_STATUS, 3,7,"Invalid Calendar User."},
00067     {ICAL_3_8_NOAUTH_STATUS, 3,8,"No authority."},
00068     {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."},
00069     {ICAL_3_10_TOOBIG_STATUS, 3,10,"Request entity too large."},
00070     {ICAL_3_11_MISSREQCOMP_STATUS, 3,11,"Required component or property missing."},
00071     {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."},
00072     {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"},
00073     {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."},
00074     {ICAL_3_15_INVCOMMAND, 3,15,"Invalid command."},
00075     {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time  is busy."},
00076     {ICAL_4_1_STORE_ACCESS_DENIED, 4,1,"Store Access Denied."},
00077     {ICAL_4_2_STORE_FAILED, 4,2,"Store Failed."},
00078     {ICAL_4_3_STORE_NOT_FOUND, 4,3,"Store not found."},
00079     {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."},
00080     {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."},
00081     {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."},
00082     {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for  user."},
00083     {ICAL_6_1_CONTAINER_NOT_FOUND, 6,1,"Container not found."},
00084     {ICAL_9_0_UNRECOGNIZED_COMMAND, 9,0,"An unrecognized command was received."},
00085     {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"}
00086 };
00087 
00088 
00089 /*** @brief Return the descriptive text for a request status
00090  */
00091 const char* icalenum_reqstat_desc(icalrequeststatus stat)
00092 {
00093     int i;
00094 
00095     for (i=0; request_status_map[i].kind  != ICAL_UNKNOWN_STATUS; i++) {
00096        if ( request_status_map[i].kind ==  stat) {
00097            return request_status_map[i].str;
00098        }
00099     }
00100 
00101     return 0;
00102 }
00103 
00104 /*** @brief Return the code for a request status
00105  */
00106 char* icalenum_reqstat_code(icalrequeststatus stat)
00107 {
00108     int i, major, minor;
00109     char tmpbuf[36];
00110 
00111     for (i=0; request_status_map[i].kind  != ICAL_UNKNOWN_STATUS; i++) {
00112        if ( request_status_map[i].kind ==  stat) {
00113            major = request_status_map[i].major;
00114            minor = request_status_map[i].minor;
00115            sprintf(tmpbuf, "%i.%i", major, minor);
00116            return icalmemory_tmp_copy(tmpbuf);
00117        }
00118     }
00119     return NULL;
00120 }
00121 
00122 /*** @brief Return the major number for a request status
00123  */
00124 short icalenum_reqstat_major(icalrequeststatus stat)
00125 {
00126     int i;
00127 
00128     for (i=0; request_status_map[i].kind  != ICAL_UNKNOWN_STATUS; i++) {
00129        if ( request_status_map[i].kind ==  stat) {
00130            return request_status_map[i].major;
00131        }
00132     }
00133     return -1;
00134 }
00135 
00136 /*** @brief Return the minor number for a request status
00137  */
00138 short icalenum_reqstat_minor(icalrequeststatus stat)
00139 {
00140     int i;
00141 
00142     for (i=0; request_status_map[i].kind  != ICAL_UNKNOWN_STATUS; i++) {
00143        if ( request_status_map[i].kind ==  stat) {
00144            return request_status_map[i].minor;
00145        }
00146     }
00147     return -1;
00148 }
00149 
00150 
00151 /*** @brief Return a request status for major/minor status numbers
00152  */
00153 icalrequeststatus icalenum_num_to_reqstat(short major, short minor)
00154 {
00155     int i;
00156 
00157     for (i=0; request_status_map[i].kind  != ICAL_UNKNOWN_STATUS; i++) {
00158        if ( request_status_map[i].major ==  major && request_status_map[i].minor ==  minor) {
00159            return request_status_map[i].kind;
00160        }
00161     }
00162     return 0;
00163 }
00164 
00165 
00166