/* * For parser only. */ extern CSA_return_code _DtCmsInsertEntry4Parser(_DtCmsCalendar *cal, cms_entry *entry) { cms_entry *eptr; CSA_return_code stat; if ((stat = _DtCmsMakeHashedEntry(cal, entry->num_attrs, entry->attrs, &eptr)) != CSA_SUCCESS) return (stat); eptr->key = entry->key; stat = _DtCmsInsertEntry(cal, eptr); _DtCm_free_cms_entry(eptr); return(stat); }
extern cms_entry_res * cms_update_entry_5_svc(cms_update_args *args, struct svc_req *svcrq) { static cms_entry_res res; _DtCmsCalendar *cal; cms_entry *newentry; caddr_t event; char *user; uint access, needaccess; Appt_4 *appt = NULL; if (debug) fprintf(stderr, "cms_update_entry_5_svc called\n"); if (res.entry != NULL) { res.entry->num_attrs--; _DtCm_free_cms_entry(res.entry); res.entry = NULL; } if ((res.stat = _DtCmsV5LoadAndCheckAccess(svcrq, args->cal, &user, &access, &cal)) != CSA_SUCCESS) return (&res); if ((cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION && !_DTCMS_HAS_CHANGE_ACCESS(access)) || (cal->fversion < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION && !_DTCMS_HAS_V4_WRITE_ACCESS(access))) { res.stat = CSA_E_NO_AUTHORITY; return (&res); } /* check argument */ if (args->cal == NULL || args->entry.id <= 0 || args->num_attrs == 0) { res.stat = CSA_E_INVALID_PARAMETER; return (&res); } if (args->scope < CSA_SCOPE_ALL || args->scope > CSA_SCOPE_FORWARD) { res.stat = CSA_E_INVALID_ENUM; return (&res); } /* check validity of attribute values */ if ((res.stat = _DtCm_check_entry_cms_attributes( (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION ? cal->fversion : _DtCM_FIRST_EXTENSIBLE_DATA_VERSION - 1), args->num_attrs, args->attrs, CSA_CB_ENTRY_UPDATED, B_TRUE)) != CSA_SUCCESS) return (&res); /* get event from one-time event tree */ event = (caddr_t)rb_lookup(cal->tree, (caddr_t)&args->entry); /* update entry and log it */ if (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION) { if (event != NULL || args->scope == CSA_SCOPE_ALL) { res.stat = _DtCmsUpdateEntry(cal, user, access, &args->entry, args->num_attrs, args->attrs, NULL, &newentry); } else { res.stat = _DtCmsUpdateInstances(cal, user, access, &args->entry, args->scope, args->num_attrs, args->attrs, NULL, &newentry); } } else { Options_4 opt; if (event != NULL || args->scope == CSA_SCOPE_ALL) opt = do_all_4; else opt = (args->scope == CSA_SCOPE_ONE) ? do_one_4 : do_forward_4; if (event == NULL && (event = hc_lookup(cal->list, (caddr_t)&args->entry)) == NULL) { res.stat = CSA_X_DT_E_ENTRY_NOT_FOUND; } else if ((appt = _DtCm_copy_one_appt4((Appt_4 *)event)) == NULL) { res.stat = CSA_E_INSUFFICIENT_MEMORY; } else { /* get rid of exceptions */ _DtCm_free_excpt4(appt->exception); appt->exception = NULL; if ((res.stat = _DtCmsAttrsToAppt4(args->num_attrs, args->attrs, appt, B_TRUE)) == CSA_SUCCESS) { if (opt == do_all_4) res.stat = _DtCmsChangeAll(cal, user, access, (Id_4 *)&args->entry, appt, NULL); else res.stat = _DtCmsChangeSome(cal, user, access, (Id_4 *)&args->entry, appt, opt, NULL); } } } if (res.stat == CSA_SUCCESS) cal->modified = B_TRUE; else return (&res); /* do callback */ cal->rlist = _DtCmsDoV1CbForV4Data(cal->rlist, user, args->pid, &args->entry, (appt ? (cms_key *)&appt->appt_id : &newentry->key)); cal->rlist = _DtCmsDoUpdateEntryCallback(cal->rlist, cal->calendar, user, (appt ? appt->appt_id.key : newentry->key.id), args->entry.id, args->scope, args->entry.time, args->pid); /* reply */ if (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION || (cal->fversion < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION && (res.stat = _DtCmsAppt4ToCmsentriesForClient(cal->calendar, appt, &newentry)) == CSA_SUCCESS)) { res.stat = _DtCmsGetCmsEntryForClient(newentry, &res.entry, B_FALSE); _DtCm_free_cms_entry(newentry); } return (&res); }
extern cms_entry_res * cms_insert_entry_5_svc(cms_insert_args *args, struct svc_req *svcrq) { static cms_entry_res res; _DtCmsCalendar *cal; cms_entry *entry; cms_key key; char *user; uint access, needaccess; Appt_4 *appt; if (debug) fprintf(stderr, "cms_insert_entry_5_svc called\n"); if (res.entry != NULL) { res.entry->num_attrs--; _DtCm_free_cms_entry(res.entry); res.entry = NULL; } if ((res.stat = _DtCmsV5LoadAndCheckAccess(svcrq, args->cal, &user, &access, &cal)) != CSA_SUCCESS) return (&res); if ((cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION && !_DTCMS_HAS_INSERT_ACCESS(access)) || (cal->fversion < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION && !_DTCMS_HAS_V4_WRITE_ACCESS(access))) { res.stat = CSA_E_NO_AUTHORITY; return (&res); } /* check argument */ if (args->cal == NULL || args->num_attrs == 0) { res.stat = CSA_E_INVALID_PARAMETER; return (&res); } /* check validity of attribute values */ if ((res.stat = _DtCm_check_entry_cms_attributes( (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION ? cal->fversion : _DtCM_FIRST_EXTENSIBLE_DATA_VERSION - 1), args->num_attrs, args->attrs, CSA_CB_ENTRY_ADDED, B_TRUE)) != CSA_SUCCESS) return (&res); if (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION) { if ((res.stat = _DtCmsMakeHashedEntry(cal, args->num_attrs, args->attrs, &entry)) != CSA_SUCCESS) return (&res); if ((res.stat = _DtCmsCheckInitialAttributes(entry)) != CSA_SUCCESS) { _DtCm_free_cms_entry(entry); return (&res); } /* check access rights */ needaccess = _DtCmsClassToInsertAccess(entry); if ((access & (CSA_OWNER_RIGHTS | needaccess)) == 0) { _DtCm_free_cms_entry(entry); res.stat = CSA_E_NO_AUTHORITY; return (&res); } /* set organizer */ if ((res.stat = _DtCm_set_string_attrval(user, &entry->attrs[CSA_ENTRY_ATTR_ORGANIZER_I].value, CSA_VALUE_CALENDAR_USER)) != CSA_SUCCESS) { _DtCm_free_cms_entry(entry); return (&res); } /* insert entry and log it */ if ((res.stat = _DtCmsInsertEntryAndLog(cal, entry)) != CSA_SUCCESS) { _DtCm_free_cms_entry(entry); return (&res); } key = entry->key; } else { if ((appt = _DtCm_make_appt4(B_TRUE)) == NULL) { res.stat = CSA_E_INSUFFICIENT_MEMORY; return (&res); } if ((res.stat = _DtCmsAttrsToAppt4(args->num_attrs, args->attrs, appt, B_TRUE)) != CSA_SUCCESS) { _DtCm_free_appt4(appt); return (&res); } if (appt->author) free(appt->author); if ((appt->author = strdup(user)) == NULL) { _DtCm_free_appt4(appt); return (&res); } /* * calculate the correct start day, */ _DtCms_adjust_appt_startdate(appt); if ((res.stat = _DtCmsInsertApptAndLog(cal, appt)) != CSA_SUCCESS) { _DtCm_free_appt4(appt); return (&res); } key.id = appt->appt_id.key; key.time = appt->appt_id.tick; } if (res.stat == CSA_SUCCESS) cal->modified = B_TRUE; else return (&res); /* do callback */ cal->rlist = _DtCmsDoV1CbForV4Data(cal->rlist, user, args->pid, &key, NULL); cal->rlist = _DtCmsDoInsertEntryCallback(cal->rlist, cal->calendar, user, key.id, args->pid); /* reply */ if (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION || (cal->fversion < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION && (res.stat = _DtCmsAppt4ToCmsentriesForClient(cal->calendar, appt, &entry)) == CSA_SUCCESS)) { res.stat = _DtCmsGetCmsEntryForClient(entry, &res.entry, B_FALSE); _DtCm_free_cms_entry(entry); } return (&res); }