Back to index

lightning-sunbird  0.9+nobinonly
Functions
icalvalue.h File Reference
#include <time.h>
#include "icalenums.h"
#include "icaltypes.h"
#include "icalrecur.h"
#include "icalduration.h"
#include "icalperiod.h"
#include "icalderivedproperty.h"
#include "icalderivedparameter.h"
#include "icalderivedvalue.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

icalvalue * icalvalue_new (icalvalue_kind kind)
icalvalue * icalvalue_new_clone (const icalvalue *value)
icalvalue * icalvalue_new_from_string (icalvalue_kind kind, const char *str)
void icalvalue_free (icalvalue *value)
int icalvalue_is_valid (const icalvalue *value)
const char * icalvalue_as_ical_string (const icalvalue *value)
icalvalue_kind icalvalue_isa (const icalvalue *value)
int icalvalue_isa_value (void *)
icalparameter_xliccomparetype icalvalue_compare (const icalvalue *a, const icalvalue *b)
icalvalue * icalvalue_new_recur (struct icalrecurrencetype v)
void icalvalue_set_recur (icalvalue *value, struct icalrecurrencetype v)
struct icalrecurrencetype icalvalue_get_recur (const icalvalue *value)
icalvalue * icalvalue_new_trigger (struct icaltriggertype v)
void icalvalue_set_trigger (icalvalue *value, struct icaltriggertype v)
struct icaltriggertype icalvalue_get_trigger (const icalvalue *value)
icalvalue * icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v)
void icalvalue_set_datetimeperiod (icalvalue *value, struct icaldatetimeperiodtype v)
struct icaldatetimeperiodtype icalvalue_get_datetimeperiod (const icalvalue *value)
icalvalue_kind icalvalue_string_to_kind (const char *str)
const char * icalvalue_kind_to_string (const icalvalue_kind kind)
int icalvalue_kind_is_valid (const icalvalue_kind kind)
 Check validity of a specific icalvalue_kind.
int icalvalue_encode_ical_string (const char *szText, char *szEncText, int MaxBufferLen)
 Encode a character string in ical format, esacpe certain characters, etc.

Function Documentation

const char* icalvalue_as_ical_string ( const icalvalue *  value)

Definition at line 969 of file icalvalue.c.

{
    if(value == 0){
       return 0;
    }

    switch (value->kind){

    case ICAL_ATTACH_VALUE:
        return icalvalue_attach_as_ical_string(value);
        
    case ICAL_BINARY_VALUE:
        return icalvalue_binary_as_ical_string(value);
        
    case ICAL_BOOLEAN_VALUE:
    case ICAL_INTEGER_VALUE:
        return icalvalue_int_as_ical_string(value);                  
        
    case ICAL_UTCOFFSET_VALUE:
        return icalvalue_utcoffset_as_ical_string(value);                  
        
    case ICAL_TEXT_VALUE:
        return icalvalue_text_as_ical_string(value);
        
    case ICAL_QUERY_VALUE:
        return icalvalue_string_as_ical_string(value);
        
    case ICAL_STRING_VALUE:
    case ICAL_URI_VALUE:
    case ICAL_CALADDRESS_VALUE:
        return icalvalue_string_as_ical_string(value);
        
    case ICAL_DATE_VALUE:
        return icalvalue_date_as_ical_string(value);
    case ICAL_DATETIME_VALUE:
        return icalvalue_datetime_as_ical_string(value);
    case ICAL_DURATION_VALUE:
        return icalvalue_duration_as_ical_string(value);
        
    case ICAL_PERIOD_VALUE:
        return icalvalue_period_as_ical_string(value);
    case ICAL_DATETIMEPERIOD_VALUE:
        return icalvalue_datetimeperiod_as_ical_string(value);
        
    case ICAL_FLOAT_VALUE:
        return icalvalue_float_as_ical_string(value);
        
    case ICAL_GEO_VALUE:
        return icalvalue_geo_as_ical_string(value);
        
    case ICAL_RECUR_VALUE:
        return icalvalue_recur_as_ical_string(value);
        
    case ICAL_TRIGGER_VALUE:
        return icalvalue_trigger_as_ical_string(value);

    case ICAL_REQUESTSTATUS_VALUE:
        return icalreqstattype_as_string(value->data.v_requeststatus);
        
    case ICAL_ACTION_VALUE:
    case ICAL_CMD_VALUE:
    case ICAL_QUERYLEVEL_VALUE:
    case ICAL_CARLEVEL_VALUE:
    case ICAL_METHOD_VALUE:
    case ICAL_STATUS_VALUE:
    case ICAL_TRANSP_VALUE:
    case ICAL_CLASS_VALUE:
        if(value->x_value !=0){
            return icalmemory_tmp_copy(value->x_value);
        }

        return icalproperty_enum_to_string(value->data.v_enum);
        
    case ICAL_X_VALUE: 
       if (value->x_value != 0)
            return icalmemory_tmp_copy(value->x_value);

    /* FALLTHRU */

    case ICAL_NO_VALUE:
    default:
       {
           return 0;
       }
    }
}

Here is the call graph for this function:

icalparameter_xliccomparetype icalvalue_compare ( const icalvalue *  a,
const icalvalue *  b 
)

Definition at line 1101 of file icalvalue.c.

{

    icalerror_check_arg_rz( (a!=0), "a");
    icalerror_check_arg_rz( (b!=0), "b");

    /* Not the same type; they can only be unequal */
    if( ! (icalvalue_is_time(a) && icalvalue_is_time(b)) &&
       icalvalue_isa(a) != icalvalue_isa(b)){
       return ICAL_XLICCOMPARETYPE_NOTEQUAL;
    }

    switch (icalvalue_isa(a)){

       case ICAL_ATTACH_VALUE:
       {
           if (icalattach_get_is_url(a->data.v_attach) &&
               icalattach_get_is_url(b->data.v_attach)) {
              if (strcasecmp(icalattach_get_url(a->data.v_attach),
                            icalattach_get_url(b->data.v_attach)) == 0)
                  return ICAL_XLICCOMPARETYPE_EQUAL;
              else
                  return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }
           else {
               if (a->data.v_attach == b->data.v_attach)
                  return ICAL_XLICCOMPARETYPE_EQUAL;
               else
                  return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }
       }
        case ICAL_BINARY_VALUE:
       {
           if (a->data.v_attach == b->data.v_attach)
              return ICAL_XLICCOMPARETYPE_EQUAL;
           else
              return ICAL_XLICCOMPARETYPE_NOTEQUAL;
       }

       case ICAL_BOOLEAN_VALUE:
       {
           if (icalvalue_get_boolean(a) == icalvalue_get_boolean(b)){
              return ICAL_XLICCOMPARETYPE_EQUAL;
           } else {
              return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }
       }

       case ICAL_FLOAT_VALUE:
       {
           if (a->data.v_float > b->data.v_float){
              return ICAL_XLICCOMPARETYPE_GREATER;
           } else if (a->data.v_float < b->data.v_float){
              return ICAL_XLICCOMPARETYPE_LESS;
           } else {
              return ICAL_XLICCOMPARETYPE_EQUAL;
           }
       }

       case ICAL_INTEGER_VALUE:
       case ICAL_UTCOFFSET_VALUE:
       {
           if (a->data.v_int > b->data.v_int){
              return ICAL_XLICCOMPARETYPE_GREATER;
           } else if (a->data.v_int < b->data.v_int){
              return ICAL_XLICCOMPARETYPE_LESS;
           } else {
              return ICAL_XLICCOMPARETYPE_EQUAL;
           }
       }

       case ICAL_DURATION_VALUE: 
       {
           int dur_a = icaldurationtype_as_int(a->data.v_duration);
           int dur_b = icaldurationtype_as_int(b->data.v_duration);

           if (dur_a > dur_b){
              return ICAL_XLICCOMPARETYPE_GREATER;
           } else if (dur_a < dur_b){
              return ICAL_XLICCOMPARETYPE_LESS;
           } else {
              return ICAL_XLICCOMPARETYPE_EQUAL;
           }
       }          


       case ICAL_TEXT_VALUE:
       case ICAL_URI_VALUE:
       case ICAL_CALADDRESS_VALUE:
       case ICAL_TRIGGER_VALUE:
       case ICAL_DATE_VALUE:
       case ICAL_DATETIME_VALUE:
       case ICAL_DATETIMEPERIOD_VALUE:
       case ICAL_QUERY_VALUE:
       case ICAL_RECUR_VALUE:
       {
           int r;

           r =  strcmp(icalvalue_as_ical_string(a),
                       icalvalue_as_ical_string(b));

           if (r > 0) {     
              return ICAL_XLICCOMPARETYPE_GREATER;
           } else if (r < 0){
              return ICAL_XLICCOMPARETYPE_LESS;
           } else {
              return ICAL_XLICCOMPARETYPE_EQUAL;
           }

              
       }

       case ICAL_METHOD_VALUE:
       {
           if (icalvalue_get_method(a) == icalvalue_get_method(b)){
              return ICAL_XLICCOMPARETYPE_EQUAL;
           } else {
              return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }

       }

       case ICAL_STATUS_VALUE:
       {
           if (icalvalue_get_status(a) == icalvalue_get_status(b)){
              return ICAL_XLICCOMPARETYPE_EQUAL;
           } else {
              return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }

       }

       case ICAL_TRANSP_VALUE:
       {
           if (icalvalue_get_transp(a) == icalvalue_get_transp(b)){
              return ICAL_XLICCOMPARETYPE_EQUAL;
           } else {
              return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }
       }

       case ICAL_ACTION_VALUE:
        {
           if (icalvalue_get_action(a) == icalvalue_get_action(b)){
              return ICAL_XLICCOMPARETYPE_EQUAL;
           } else {
              return ICAL_XLICCOMPARETYPE_NOTEQUAL;
           }
        }

       case ICAL_PERIOD_VALUE:
       case ICAL_GEO_VALUE:
       case ICAL_NO_VALUE:
       default:
       {
           icalerror_warn("Comparison not implemented for value type");
           return 0;
       }
    }   

}

Here is the call graph for this function:

int icalvalue_encode_ical_string ( const char *  szText,
char *  szEncText,
int  MaxBufferLen 
)

Encode a character string in ical format, esacpe certain characters, etc.

Definition at line 1293 of file icalvalue.c.

{
    char   *ptr;
    icalvalue *value = 0;

    if ((szText == 0) || (szEncText == 0))
        return 0;
   
    value = icalvalue_new_from_string(ICAL_STRING_VALUE, szText);
    
    if (value == 0)
        return 0;
    
    ptr = icalvalue_text_as_ical_string(value);
    if (ptr == 0)
        return 0;
    
    if ((int)strlen(ptr) >= nMaxBufferLen)
        {
            icalvalue_free (value);
            return 0;
        }

    strcpy(szEncText, ptr);

    icalvalue_free ((icalvalue*)value);

    return 1;
}

Here is the call graph for this function:

void icalvalue_free ( icalvalue *  value)

Definition at line 568 of file icalvalue.c.

{
    icalerror_check_arg_rv((v != 0),"value");

#ifdef ICAL_FREE_ON_LIST_IS_ERROR
    icalerror_assert( (v->parent ==0),"This value is still attached to a property");
    
#else
    if(v->parent !=0){
       return;
    }
#endif

    if(v->x_value != 0){
        free(v->x_value);
    }

    switch (v->kind){
       case ICAL_BINARY_VALUE: 
       case ICAL_ATTACH_VALUE: {
           if (v->data.v_attach) {
              icalattach_unref (v->data.v_attach);
              v->data.v_attach = NULL;
           }

           break;
       }
       case ICAL_TEXT_VALUE:
       case ICAL_CALADDRESS_VALUE:
       case ICAL_URI_VALUE:
       case ICAL_QUERY_VALUE:
       {
           if (v->data.v_string != 0) { 
              free((void*)v->data.v_string);
              v->data.v_string = 0;
           }
           break;
       }
       case ICAL_RECUR_VALUE:
       {
           if(v->data.v_recur != 0){
              free((void*)v->data.v_recur);
              v->data.v_recur = 0;
           }
           break;
       }

       default:
       {
           /* Nothing to do */
       }
    }

    v->kind = ICAL_NO_VALUE;
    v->size = 0;
    v->parent = 0;
    memset(&(v->data),0,sizeof(v->data));
    v->id[0] = 'X';
    free(v);
}

Here is the call graph for this function:

struct icaldatetimeperiodtype icalvalue_get_datetimeperiod ( const icalvalue *  value) [read]

Definition at line 928 of file icalderivedvalue.c.

{
  struct icaldatetimeperiodtype dtp;
  
  icalerror_check_arg( (impl!=0),"value");
  icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);
  
  if(impl->kind == ICAL_DATETIME_VALUE){
      dtp.period = icalperiodtype_null_period();
      dtp.time = impl->data.v_time;
  } else if(impl->kind == ICAL_PERIOD_VALUE) {
      dtp.period = impl->data.v_period;
      dtp.time = icaltime_null_time();
  } else {
      dtp.period = icalperiodtype_null_period();
      dtp.time = icaltime_null_time();
      icalerror_set_errno(ICAL_BADARG_ERROR);
  }    

  return dtp;
}

Here is the call graph for this function:

struct icalrecurrencetype icalvalue_get_recur ( const icalvalue *  value) [read]

Definition at line 831 of file icalderivedvalue.c.

{
    icalerror_check_arg( (value!=0),"value");
    icalerror_check_value_type(value, ICAL_RECUR_VALUE);
  
    return *(value->data.v_recur);
}
struct icaltriggertype icalvalue_get_trigger ( const icalvalue *  value) [read]

Definition at line 867 of file icalderivedvalue.c.

{
    struct icaltriggertype tr;

    icalerror_check_arg( (impl!=0),"value");
    icalerror_check_arg( (impl!=0),"value");

    if(impl->kind == ICAL_DATETIME_VALUE){
        tr.duration = icaldurationtype_from_int(0);
        tr.time = impl->data.v_time;
    } else if(impl->kind == ICAL_DURATION_VALUE){
       tr.time = icaltime_null_time();
       tr.duration = impl->data.v_duration;
    } else {
       tr.duration = icaldurationtype_from_int(0);
       tr.time = icaltime_null_time();
       icalerror_set_errno(ICAL_BADARG_ERROR);
    }

    return tr;
}

Here is the call graph for this function:

int icalvalue_is_valid ( const icalvalue *  value)

Definition at line 630 of file icalvalue.c.

{
    if(value == 0){
       return 0;
    }
    
    return 1;
}
icalvalue_kind icalvalue_isa ( const icalvalue *  value)

Definition at line 1058 of file icalvalue.c.

{
    if(value == 0){
       return ICAL_NO_VALUE;
    }

    return value->kind;
}

Definition at line 1069 of file icalvalue.c.

{
    struct icalvalue_impl *impl = (struct icalvalue_impl *)value;

    icalerror_check_arg_rz( (value!=0), "value");

    if (strcmp(impl->id,"val") == 0) {
       return 1;
    } else {
       return 0;
    }
}

Check validity of a specific icalvalue_kind.

Definition at line 732 of file icalderivedvalue.c.

{
    int i = 0;
    do {
      if (value_map[i].kind == kind)
       return 1;
    } while (value_map[i++].kind != ICAL_NO_VALUE);

    return 0;
}  

Definition at line 743 of file icalderivedvalue.c.

{
    int i;

    for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
       if (value_map[i].kind == kind) {
           return value_map[i].name;
       }
    }

    return 0;
}
icalvalue* icalvalue_new ( icalvalue_kind  kind)

Definition at line 94 of file icalvalue.c.

{
    return (icalvalue*)icalvalue_new_impl(kind);
}

Here is the call graph for this function:

icalvalue* icalvalue_new_clone ( const icalvalue *  value)

Definition at line 99 of file icalvalue.c.

                                                     {
    struct icalvalue_impl* new;

    new = icalvalue_new_impl(old->kind);

    if (new == 0){
       return 0;
    }

    strcpy(new->id, old->id);
    new->kind = old->kind;
    new->size = old->size;

    switch (new->kind){
       case ICAL_ATTACH_VALUE: 
       case ICAL_BINARY_VALUE: 
       {
           /* Hmm.  We just ref the attach value, which may not be the right
            * thing to do.  We cannot quite copy the data, anyways, since we
            * don't know how long it is.
            */
           new->data.v_attach = old->data.v_attach;
           if (new->data.v_attach)
              icalattach_ref (new->data.v_attach);

           break;
       }
       case ICAL_QUERY_VALUE:
       case ICAL_STRING_VALUE:
       case ICAL_TEXT_VALUE:
       case ICAL_CALADDRESS_VALUE:
       case ICAL_URI_VALUE:
       {
           if (old->data.v_string != 0) { 
              new->data.v_string=icalmemory_strdup(old->data.v_string);

              if ( new->data.v_string == 0 ) {
                  return 0;
              }                 

           }
           break;
       }
       case ICAL_RECUR_VALUE:
       {
           if(old->data.v_recur != 0){
              new->data.v_recur = malloc(sizeof(struct icalrecurrencetype));

              if(new->data.v_recur == 0){
                  return 0;
              }

              memcpy(       new->data.v_recur, old->data.v_recur,
                     sizeof(struct icalrecurrencetype));       
           }
           break;
       }

       case ICAL_X_VALUE: 
       {
           if (old->x_value != 0) {
              new->x_value=icalmemory_strdup(old->x_value);

              if (new->x_value == 0) {
                  return 0;
              }
           }

           break;
       }

       default:
       {
           /* all of the other types are stored as values, not
               pointers, so we can just copy the whole structure. */

           new->data = old->data;
       }
    }

    return new;
}

Here is the call graph for this function:

Definition at line 892 of file icalderivedvalue.c.

{
   struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE);

   icalvalue_set_datetimeperiod(impl,v);

   return (icalvalue*)impl;
}

Here is the call graph for this function:

icalvalue* icalvalue_new_from_string ( icalvalue_kind  kind,
const char *  str 
)

Definition at line 560 of file icalvalue.c.

{
    return icalvalue_new_from_string_with_error(kind,str,(icalproperty**)0);
}

Here is the call graph for this function:

icalvalue* icalvalue_new_recur ( struct icalrecurrencetype  v)

Definition at line 799 of file icalderivedvalue.c.

{
   struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE);
    
   icalvalue_set_recur((icalvalue*)impl,v);

   return (icalvalue*)impl;
}

Here is the call graph for this function:

icalvalue* icalvalue_new_trigger ( struct icaltriggertype  v)

Definition at line 843 of file icalderivedvalue.c.

{
   struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE);
 
   icalvalue_set_trigger((icalvalue*)impl,v);

   return (icalvalue*)impl;
}

Here is the call graph for this function:

void icalvalue_set_datetimeperiod ( icalvalue *  value,
struct icaldatetimeperiodtype  v 
)

Definition at line 902 of file icalderivedvalue.c.

Here is the call graph for this function:

void icalvalue_set_recur ( icalvalue *  value,
struct icalrecurrencetype  v 
)

Definition at line 809 of file icalderivedvalue.c.

{
    icalerror_check_arg_rv( (impl!=0),"value");
    icalerror_check_value_type(value, ICAL_RECUR_VALUE);

    if (impl->data.v_recur != 0){
       free(impl->data.v_recur);
       impl->data.v_recur = 0;
    }

    impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype));

    if (impl->data.v_recur == 0){
       icalerror_set_errno(ICAL_NEWFAILED_ERROR);
       return;
    } else {
       memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype));
    }
              
}

Here is the call graph for this function:

void icalvalue_set_trigger ( icalvalue *  value,
struct icaltriggertype  v 
)

Definition at line 853 of file icalderivedvalue.c.

Here is the call graph for this function:

Definition at line 756 of file icalderivedvalue.c.

{
    int i;

    for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) {
       if (strcmp(value_map[i].name,str) == 0) {
           return value_map[i].kind;
       }
    }

    return  value_map[i].kind;

}