예제 #1
0
void icalattach_ref(icalattach *attach)
{
    icalerror_check_arg_rv((attach != NULL), "attach");
    icalerror_check_arg_rv((attach->refcount > 0), "attach->refcount > 0");

    attach->refcount++;
}
void icalvalue_set_x(icalvalue* impl, const char* v) {
    icalerror_check_arg_rv( (impl!=0),"value");
    icalerror_check_arg_rv( (v!=0),"v");

    if(impl->x_value!=0) {free((void*)impl->x_value);}

    impl->x_value = icalmemory_strdup(v);

    if (impl->x_value == 0){
      errno = ENOMEM;
    }
 
 }
예제 #3
0
static void icaldirset_add_uid(icalcomponent *comp)
{
    char uidstring[MAXPATHLEN] = { 0 };
    icalproperty *uid;

#if defined(HAVE_SYS_UTSNAME_H)
    struct utsname unamebuf;
#endif

    icalerror_check_arg_rv((comp != 0), "comp");

    uid = icalcomponent_get_first_property(comp, ICAL_UID_PROPERTY);

    if (uid == 0) {

#if defined(HAVE_SYS_UTSNAME_H)
        uname(&unamebuf);
        snprintf(uidstring, sizeof(uidstring), "%d-%s", (int)getpid(), unamebuf.nodename);
#else
        /* FIXME: There must be an easy get the system name */
        snprintf(uidstring, sizeof(uidstring), "%d-%s", (int)getpid(), "WINDOWS");
#endif
        uid = icalproperty_new_uid(uidstring);
        icalcomponent_add_property(comp, uid);
    } else {
        strncpy(uidstring, icalproperty_get_uid(uid), MAXPATHLEN - 1);
        uidstring[MAXPATHLEN - 1] = '\0';
    }
}
void
icalvalue_set_datetimeperiod(icalvalue* impl, struct icaldatetimeperiodtype v)
{
    icalerror_check_arg_rv( (impl!=0),"value");
    
    icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE);

    if(!icaltime_is_null_time(v.time)){
	if(!icaltime_is_valid_time(v.time)){
	    icalerror_set_errno(ICAL_BADARG_ERROR);
	    return;
	}
	impl->kind = ICAL_DATETIME_VALUE;
	icalvalue_set_datetime(impl,v.time);
    } else if (!icalperiodtype_is_null_period(v.period)) {
	if(!icalperiodtype_is_valid_period(v.period)){
	    icalerror_set_errno(ICAL_BADARG_ERROR);
	    return;
	}
	impl->kind = ICAL_PERIOD_VALUE;
	icalvalue_set_period(impl,v.period);
    } else {
	icalerror_set_errno(ICAL_BADARG_ERROR);
    }
}
예제 #5
0
static void icaldirset_add_uid(icalcomponent* comp)
{
    char uidstring[ICAL_PATH_MAX];
    icalproperty *uid;
#ifndef WIN32
    struct utsname unamebuf;
#endif

    icalerror_check_arg_rv( (comp!=0), "comp");

    uid = icalcomponent_get_first_property(comp,ICAL_UID_PROPERTY);
    
    if (uid == 0) {
	
#ifndef WIN32
	uname(&unamebuf);
	
	snprintf(uidstring,sizeof(uidstring),"%d-%s",(int)getpid(),unamebuf.nodename);
#else
	snprintf(uidstring,sizeof(uidstring),"%d-%s",(int)getpid(),"WINDOWS");  /* FIX: There must be an easy get the system name */
#endif
	
	uid = icalproperty_new_uid(uidstring);
	icalcomponent_add_property(comp,uid);
    } else {
	strcpy(uidstring,icalproperty_get_uid(uid));
    }
}
예제 #6
0
/* XXX add more to this */
void icalbdbset_free(icalset *set)
{
    icalbdbset *bset = (icalbdbset *) set;
    int ret;

    icalerror_check_arg_rv((bset != 0), "bset");

    if (bset->cluster != 0) {
        (void)icalbdbset_commit(set);
        icalcomponent_free(bset->cluster);
        bset->cluster = 0;
    }

    if (bset->gauge != 0) {
        icalgauge_free(bset->gauge);
    }

    if (bset->path != 0) {
        free((char *)bset->path);
        bset->path = 0;
    }

    if (bset->sindex != 0) {
        free((char *)bset->sindex);
        bset->sindex = 0;
    }

    if (bset->dbp && ((ret = bset->dbp->close(bset->dbp, 0)) != 0)) {
    }
    bset->dbp = NULL;
}
예제 #7
0
void icalbdbset_mark(icalset *set)
{
    icalbdbset *bset = (icalbdbset *) set;

    icalerror_check_arg_rv((bset != 0), "bset");

    bset->changed = 1;
}
예제 #8
0
void icalbdbset_clear(icalset *set)
{
    icalbdbset *bset = (icalbdbset *) set;

    icalerror_check_arg_rv((bset != 0), "bset");

    bset->gauge = 0;
}
예제 #9
0
void
icalattach_unref (icalattach *attach)
{
    icalerror_check_arg_rv ((attach != NULL), "attach");
    icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0");

    attach->refcount--;

    if (attach->refcount != 0)
	return;

    if (attach->is_url)
	free (attach->u.url.url);
    else if (attach->u.data.free_fn)
	(* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data);

    free (attach);
}
void
icalvalue_set_attach (icalvalue *value, icalattach *attach)
{
    struct icalvalue_impl *impl;
 
    icalerror_check_arg_rv ((value != NULL), "value");
    icalerror_check_value_type (value, ICAL_ATTACH_VALUE);
    icalerror_check_arg_rv ((attach != NULL), "attach");
  
    impl = (struct icalvalue_impl *) value;
 
    icalattach_ref (attach);

    if (impl->data.v_attach)
	icalattach_unref (impl->data.v_attach);
  
    impl->data.v_attach = attach;
}
void icalvalue_set_string(icalvalue* value, const char* v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    icalerror_check_arg_rv( (v!=0),"v");

    icalerror_check_value_type(value, ICAL_STRING_VALUE);
    impl = (struct icalvalue_impl*)value;
    if(impl->data.v_string!=0) {free((void*)impl->data.v_string);}


    impl->data.v_string = icalmemory_strdup(v);

    if (impl->data.v_string == 0){
      errno = ENOMEM;
    }
 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_date(icalvalue* value, struct icaltimetype v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_DATE_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_time = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_geo(icalvalue* value, struct icalgeotype v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_GEO_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_geo = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_float(icalvalue* value, float v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_FLOAT_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_float = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_status(icalvalue* value, enum icalproperty_status v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_STATUS_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_enum = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_period(icalvalue* value, struct icalperiodtype v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_PERIOD_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_period = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_xlicclass(icalvalue* value, enum icalproperty_xlicclass v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_XLICCLASS_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_enum = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_utcoffset(icalvalue* value, int v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_UTCOFFSET_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_int = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_action(icalvalue* value, enum icalproperty_action v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_ACTION_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_enum = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_duration(icalvalue* value, struct icaldurationtype v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_DURATION_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_duration = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_requeststatus(icalvalue* value, struct icalreqstattype v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_REQUESTSTATUS_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_requeststatus = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_transp(icalvalue* value, enum icalproperty_transp v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_TRANSP_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_enum = v; 

    icalvalue_reset_kind(impl);
}
void icalvalue_set_boolean(icalvalue* value, int v) {
    struct icalvalue_impl* impl; 
    icalerror_check_arg_rv( (value!=0),"value");
    
    icalerror_check_value_type(value, ICAL_BOOLEAN_VALUE);
    impl = (struct icalvalue_impl*)value;


    impl->data.v_int = v; 

    icalvalue_reset_kind(impl);
}
void
icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v)
{
    icalerror_check_arg_rv( (value!=0),"value");
    
   if(!icaltime_is_null_time(v.time)){
       icalvalue_set_datetime(value,v.time);
       value->kind = ICAL_DATETIME_VALUE;
   } else {
       icalvalue_set_duration(value,v.duration);
       value->kind = ICAL_DURATION_VALUE;
   }
}
예제 #25
0
void icalcluster_free(icalcluster *impl) {
	icalerror_check_arg_rv((impl!=0),"cluster");

	if (impl->key != 0){
		free(impl->key);
		impl->key = 0;
	}

	if (impl->data != 0){
		icalcomponent_free(impl->data);
		impl->data = 0;
	}

	free(impl);
}
void
icalvalue_set_recur(icalvalue* impl, struct icalrecurrencetype v)
{
    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));
    }
	       
}
예제 #27
0
void 
icalmemory_append_string(char** buf, char** pos, size_t* buf_size, 
			      const char* string)
{
    char *new_buf;
    char *new_pos;

    size_t data_length, final_length, string_length;

#ifndef ICAL_NO_INTERNAL_DEBUG
    icalerror_check_arg_rv( (buf!=0),"buf");
    icalerror_check_arg_rv( (*buf!=0),"*buf");
    icalerror_check_arg_rv( (pos!=0),"pos");
    icalerror_check_arg_rv( (*pos!=0),"*pos");
    icalerror_check_arg_rv( (buf_size!=0),"buf_size");
    icalerror_check_arg_rv( (*buf_size!=0),"*buf_size");
    icalerror_check_arg_rv( (string!=0),"string");
#endif 

    string_length = strlen(string);
    data_length = (size_t)*pos - (size_t)*buf;    
    final_length = data_length + string_length; 

    if ( final_length >= (size_t) *buf_size) {

	
	*buf_size  = (*buf_size) * 2  + final_length;

	new_buf = realloc(*buf,*buf_size);

	new_pos = (void*)((size_t)new_buf + data_length);
	
	*pos = new_pos;
	*buf = new_buf;
    }
    
    strcpy(*pos, string);

    *pos += string_length;
}
예제 #28
0
void 
icalmemory_append_char(char** buf, char** pos, size_t* buf_size, 
			      char ch)
{
    char *new_buf;
    char *new_pos;

    size_t data_length, final_length;

#ifndef ICAL_NO_INTERNAL_DEBUG
    icalerror_check_arg_rv( (buf!=0),"buf");
    icalerror_check_arg_rv( (*buf!=0),"*buf");
    icalerror_check_arg_rv( (pos!=0),"pos");
    icalerror_check_arg_rv( (*pos!=0),"*pos");
    icalerror_check_arg_rv( (buf_size!=0),"buf_size");
    icalerror_check_arg_rv( (*buf_size!=0),"*buf_size");
#endif

    data_length = (size_t)*pos - (size_t)*buf;

    final_length = data_length + 2; 

    if ( final_length > (size_t) *buf_size ) {

	
	*buf_size  = (*buf_size) * 2  + final_length +1;

	new_buf = realloc(*buf,*buf_size);

	new_pos = (void*)((size_t)new_buf + data_length);
	
	*pos = new_pos;
	*buf = new_buf;
    }

    **pos = ch;
    *pos += 1;
    **pos = 0;
}
예제 #29
0
void icalcluster_commit(icalcluster *impl) {
	icalerror_check_arg_rv((impl!=0),"cluster");

	impl->changed = 0;
}
예제 #30
0
void icalcluster_mark(icalcluster *impl) {
	icalerror_check_arg_rv((impl!=0),"cluster");

	impl->changed = 1;
}