Example #1
0
extern  cms_reminder_res *
cms_lookup_reminder_5_svc(cms_reminder_args *args, struct svc_req *svcrq)
{
	static cms_reminder_res res;
	_DtCmsCalendar		*cal;
	char			*user;
	uint			access;

	if (debug)
		fprintf(stderr, "cms_lookup_reminder_5_svc called\n");

	if (res.rems != NULL) {
		_DtCmsFreeReminderRef(res.rems);
		res.rems = NULL;
	}

	if ((res.stat = _DtCmsV5LoadAndCheckAccess(svcrq, args->cal, &user,
	    &access, &cal)) != CSA_SUCCESS)
		return (&res);

	if ((access & CSA_OWNER_RIGHTS) == 0) {
		res.stat = CSA_E_NO_AUTHORITY;
		return (&res);
	}

	if (cal->fversion >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION) {
		res.stat = _DtCmsLookupReminder(cal->remq, args->tick,
				args->num_names, args->names, &res.rems);
	} else {
		Reminder_4	*v4rem;
		_DtCmsEntryId	*ids;

		if ((res.stat = _DtCmsGetV4Reminders(cal, time(0), &v4rem,
		    &ids)) == CSA_SUCCESS) {
			res.stat = _DtCmsV4ReminderToReminderRef(cal->calendar,
					v4rem, ids, &res.rems);
			_DtCm_free_reminder4(v4rem);
			_DtCmsFreeEntryIds(ids);
		}
	}

	return (&res);
}
Example #2
0
File: table.c Project: juddy/edcde
extern CSA_return_code
_DtCm_table_lookup_reminder(
	Calendar *cal,
	CSA_uint32 num_names,
	char **reminder_names,
	CSA_uint32 *num_rems,
	CSA_reminder_reference **rems)
{
        CSA_return_code	stat = CSA_SUCCESS;
        Table_Res_4	*res = NULL;
	_DtCm_Connection	*conn;
	Reminder_4	*rptr;
	time_t		tick;

	DP(("table.c: _DtCm_table_lookup_reminder\n"));

	if (cal == NULL || num_rems == 0 || rems == NULL)
		return (CSA_E_INVALID_PARAMETER);

	/*
	 * Due to the implementation of existing backends which
	 * will unmanage any reminders that happens before the
	 * the given tick, the user specified tick is ignore and
	 * we will pass in the current time.
	 */
	tick = time(0);

	conn = &cal->conn;
	conn->retry = B_TRUE;

	switch(conn->ci->vers_out) {
                Table_Args_2 a2;
                Table_Args_3 a3;
                Table_Args_4 a4;
                Table_Res_2 *res2;
                Table_Res_3 *res3;
        case TABLEVERS_2:
                a2.target = cal->name;
                a2.args.tag = TICK_2;
                a2.args.Args_2_u.tick = tick;
                res2 = _DtCm_rtable_lookup_next_reminder_2(&a2, conn);
                res = _DtCm_tableres2_to_tableres4(res2);
                if (res2 != NULL)
			xdr_free((xdrproc_t)_DtCm_xdr_Table_Res_2, (char*)res2);
                break;
	case TABLEVERS_3:
                a3.target = cal->name;
                a3.args.tag = TICK_3;
                a3.args.Args_3_u.tick = tick;
		a3.pid = getpid();
                res3 = _DtCm_rtable_lookup_next_reminder_3(&a3, conn);
                res = _DtCm_tableres3_to_tableres4(res3);
                if (res3 != NULL)
			xdr_free((xdrproc_t)_DtCm_xdr_Table_Res_3, (char*)res3);
                break;
        case TABLEVERS_4:
		a4.target = cal->name;
                a4.args.tag = TICK_4;
                a4.args.Args_4_u.tick = tick;
		a4.pid = getpid();
                res = _DtCm_rtable_lookup_next_reminder_4(&a4, conn);
                break;
        default:
		stat = CSA_E_FAILURE;
		break;
        }

        if (res != NULL) {
                switch(res->status) {
                case access_ok_4:
			/*
			 * if reminder names are specified,
			 * return only those that match
			 */
			rptr = _DtCm_copy_reminder4(res->res.Table_Res_List_4_u.r);
                	xdr_free((xdrproc_t)_DtCm_xdr_Table_Res_4, (char*)res);

			if (num_names > 0 && reminder_names != NULL) {
				rptr = _DtCm_match_reminders(rptr, num_names,
					reminder_names);
			}

			stat = _DtCm_reminder4_to_csareminder(rptr, num_rems,
				rems);

			if (rptr != NULL)
				_DtCm_free_reminder4(rptr);
                        break;
		case access_notable_4:
			stat = CSA_E_CALENDAR_NOT_EXIST;
			break;
                case access_failed_4:
                case access_other_4:
                        stat = CSA_E_FAILURE;
			break;
		default:
			/* remote system error */
			DP ((errfmt, "_DtCm_table_lookup_reminder", res->status));
			stat = CSA_E_FAILURE;
			break;
                }
        } else {
		stat = (conn->stat == RPC_SUCCESS) ? CSA_E_SERVICE_UNAVAILABLE :
			_DtCm_clntstat_to_csastat(conn->stat);
	}

        return(stat);
}