|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T m
Length: 33406 (0x827e)
Types: TextFile
Names: »moperation.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦e83f91978⟧ »EurOpenD22/isode/osimis-2.0.tar.Z«
└─⟦d846658bd⟧
└─⟦this⟧ »osimis/msap/moperation.c«
/*
* Copyright (c) 1988 University College London
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the Department of Computer Science, University College London.
* The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/* moperation.c - perform the management operations */
/*
* By George Pavlou, April 1990
*/
#include <stdio.h>
#include <isode/rosap.h>
#include "msap.h"
static int M_LinkedReply(), M_Error();
static int buildfail(), rosfail(), argfail();
/* LINTLIBRARY */
int M_EventRepAux (msd, op, invoke, obj_class, obj_inst, type, time, info, mi)
int msd, op, invoke;
MID obj_class, type;
MN obj_inst;
char * time;
PE info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct event_rep_arg parm;
PE pe;
if (obj_class)
parm.ea_class = *obj_class; /* struct copy */
else
return argfail(op, 0, "Object Class");
if (obj_inst)
parm.ea_inst = *obj_inst; /* struct copy */
else
return argfail(op, 0, "Object Instance");
if (type)
parm.ea_type = *type; /* struct copy */
else
return argfail(op, 0, "Event Type");
parm.ea_time = time;
parm.ea_info = info;
if (build_CMIP_EventReportArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Event Report Argument", mi);
if (RoInvokeRequest(msd, op, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_EventRepRes (msd, invoke, obj_class, obj_inst, time, reply,
error, err_info, mi)
int msd, invoke;
MID obj_class;
MN obj_inst;
char * time;
CMISparam * reply;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct event_rep_res parm;
PE pe;
if (error)
return M_Error(msd, M_EVENT_REPC, invoke, NULLMID, NULLMN, NULLCP,
0, NULLMPARM, error, err_info, mi);
if (obj_class)
parm.er_class = *obj_class; /* struct copy */
else
parm.er_class.mid_type = MID_GLOBAL, parm.er_class.mid_global = NULLOID;
if (obj_inst)
parm.er_inst = *obj_inst; /* struct copy */
else
parm.er_inst.mn_type = MN_DN, parm.er_inst.mn_dn = NULLDN;
if (reply) {
if (reply -> mp_id.mid_type == MID_GLOBAL &&
reply -> mp_id.mid_global == NULLOID)
return argfail(M_EVENT_REPC, 1, "Reply Id");
parm.er_reply = *reply; /* struct copy */
}
else
parm.er_reply.mp_id.mid_type = MID_GLOBAL,
parm.er_reply.mp_id.mid_global = NULLOID,
parm.er_reply.mp_val = NULLPE;
parm.er_time = time;
if (build_CMIP_EventReportResult(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Event Report Result", mi);
if (RoResultRequest(msd, invoke, M_EVENT_REPC, pe, ROS_NOPRIO, &rois)
== NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_Get (msd, invoke, obj_class, obj_inst, scope, filter,
access, sync, nattrs, attrs, mi)
int msd, invoke;
MID obj_class;
MN obj_inst;
Scope * scope;
CMISfilter * filter;
External * access;
CMISsync sync;
int nattrs;
MID attrs;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct get_arg parm;
register MID attr = parm.ga_attrs;
PE pe;
if (obj_class)
parm.ga_class = *obj_class; /* struct copy */
else
return argfail(M_GET, 0, "Object Class");
if (obj_inst)
parm.ga_inst = *obj_inst; /* struct copy */
else
return argfail(M_GET, 0, "Object Instance");
if (scope)
parm.ga_scope = *scope; /* struct copy */
else
parm.ga_scope.sc_type = Sc_BaseObject;
parm.ga_filter = filter;
parm.ga_access = access;
parm.ga_sync = sync;
parm.ga_nattrs = nattrs;
for (; nattrs--;)
*attr++ = *attrs++; /* struct copy */
if (build_CMIP_GetArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Get Argument", mi);
if (RoInvokeRequest(msd, M_GET, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_GetRes (msd, invoke, linked, obj_class, obj_inst, time,
nattrs, attrs, error, err_info, mi)
int msd, invoke, linked;
MID obj_class;
MN obj_inst;
char * time;
int nattrs;
CMISparam * attrs;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct get_res parm;
register CMISparam * attr = parm.gr_attrs;
PE pe;
if (linked) {
if (linked != invoke)
return argfail(M_GET, 1, "LinkedId = InvokeId");
return M_LinkedReply(msd, M_GET, invoke, obj_class, obj_inst, time,
nattrs, attrs, NULLMPARM, error, err_info, mi);
}
if (error)
return M_Error(msd, M_GET, invoke, obj_class, obj_inst, time,
nattrs, attrs, error, err_info, mi);
if (obj_class)
parm.gr_class = *obj_class; /* struct copy */
else
parm.gr_class.mid_type = MID_GLOBAL, parm.gr_class.mid_global = NULLOID;
if (obj_inst)
parm.gr_inst = *obj_inst; /* struct copy */
else
parm.gr_inst.mn_type = MN_DN, parm.gr_inst.mn_dn = NULLDN;
parm.gr_time = time;
parm.gr_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE)
return argfail(M_GET, 1, "Attribute Value");
*attr++ = *attrs++; /* struct copy */
}
if (build_CMIP_GetResult(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Get Result", mi);
if (RoResultRequest(msd, invoke, M_GET, pe, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_SetAux (msd, op, invoke, obj_class, obj_inst, scope, filter,
access, sync, nattrs, attrs, mi)
int msd, op, invoke;
MID obj_class;
MN obj_inst;
Scope * scope;
CMISfilter * filter;
External * access;
CMISsync sync;
int nattrs;
CMISparam * attrs;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct set_arg parm;
register CMISparam * attr = parm.sa_attrs;
PE pe;
if (obj_class)
parm.sa_class = *obj_class; /* struct copy */
else
return argfail(op, 0, "Object Class");
if (obj_inst)
parm.sa_inst = *obj_inst; /* struct copy */
else
return argfail(op, 0, "Object Instance");
if (scope)
parm.sa_scope = *scope; /* struct copy */
else
parm.sa_scope.sc_type = Sc_BaseObject;
parm.sa_filter = filter;
parm.sa_access = access;
parm.sa_sync = sync;
if (!nattrs)
return argfail(op, 0, "Attribute List");
parm.sa_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE && attrs -> mp_modify != m_setToDefault)
return argfail(op, 0, "Attribute Value");
*attr++ = *attrs++; /* struct copy */
}
if (build_CMIP_SetArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Set Argument", mi);
if (RoInvokeRequest(msd, op, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return (OK);
}
int M_SetRes (msd, invoke, linked, obj_class, obj_inst, time,
nattrs, attrs, error, err_info, mi)
int msd, invoke, linked;
MID obj_class;
MN obj_inst;
char * time;
int nattrs;
CMISparam * attrs;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct set_res parm;
register CMISparam * attr = parm.sr_attrs;
PE pe;
if (linked) {
if (linked != invoke)
return argfail(M_SETC, 1, "LinkedId = InvokeId");
return M_LinkedReply(msd, M_SETC, invoke, obj_class, obj_inst, time,
nattrs, attrs, NULLMPARM, error, err_info, mi);
}
if (error)
return M_Error(msd, M_SETC, invoke, obj_class, obj_inst, time,
nattrs, attrs, error, err_info, mi);
if (obj_class)
parm.sr_class = *obj_class; /* struct copy */
else
parm.sr_class.mid_type = MID_GLOBAL, parm.sr_class.mid_global = NULLOID;
if (obj_inst)
parm.sr_inst = *obj_inst; /* struct copy */
else
parm.sr_inst.mn_type = MN_DN, parm.sr_inst.mn_dn = NULLDN;
parm.sr_time = time;
parm.sr_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE)
return argfail(M_SETC, 1, "Attribute Value");
*attr++ = *attrs++; /* struct copy */
}
if (build_CMIP_SetResult(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Set Result", mi);
if (RoResultRequest(msd, invoke, M_SETC, pe, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_ActionAux (msd, op, invoke, obj_class, obj_inst, scope, filter,
access, sync, type, info, mi)
int msd, op, invoke;
MID obj_class;
MN obj_inst;
Scope * scope;
CMISfilter * filter;
External * access;
CMISsync sync;
MID type;
PE info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct action_arg parm;
PE pe;
if (obj_class)
parm.aa_class = *obj_class; /* struct copy */
else
return argfail(op, 0, "Object Class");
if (obj_inst)
parm.aa_inst = *obj_inst; /* struct copy */
else
return argfail(op, 0, "Object Instance");
if (type)
parm.aa_info.mp_id = *type; /* struct copy */
else
return argfail(op, 0, "Type");
parm.aa_info.mp_val = info;
if (scope)
parm.aa_scope = *scope; /* struct copy */
else
parm.aa_scope.sc_type = Sc_BaseObject;
parm.aa_filter = filter;
parm.aa_access = access;
parm.aa_sync = sync;
if (build_CMIP_ActionArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Action Argument", mi);
if (RoInvokeRequest(msd, op, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_ActionRes (msd, invoke, linked, obj_class, obj_inst, time, reply,
error, err_info, mi)
int msd, invoke, linked;
MID obj_class;
MN obj_inst;
char * time;
CMISparam * reply;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct action_res parm;
PE pe;
if (linked) {
if (linked != invoke)
return argfail(M_ACTIONC, 1, "LinkedId = InvokeId");
return M_LinkedReply(msd, M_ACTIONC, invoke, obj_class, obj_inst, time,
0, NULLMPARM, reply, error, err_info, mi);
}
if (error)
return M_Error(msd, M_ACTIONC, invoke, NULLMID, NULLMN, NULLCP,
0, NULLMPARM, error, err_info, mi);
if (obj_class)
parm.ar_class = *obj_class; /* struct copy */
else
parm.ar_class.mid_type = MID_GLOBAL, parm.ar_class.mid_global = NULLOID;
if (obj_inst)
parm.ar_inst = *obj_inst; /* struct copy */
else
parm.ar_inst.mn_type = MN_DN, parm.ar_inst.mn_dn = NULLDN;
if (reply) {
if (reply -> mp_val == NULLPE)
return argfail (M_ACTIONC, 1, "Reply Value");
parm.ar_reply = *reply; /* struct copy */
}
else
parm.ar_reply.mp_id.mid_type = MID_GLOBAL,
parm.ar_reply.mp_id.mid_global = NULLOID,
parm.ar_reply.mp_val = NULLPE;
parm.ar_time = time;
if (build_CMIP_ActionResult(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Action Result", mi);
if (RoResultRequest(msd, invoke, M_ACTIONC, pe, ROS_NOPRIO, &rois)
== NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_Create (msd, invoke, obj_class, obj_inst, inst_type, ref_inst,
access, nattrs, attrs, mi)
int msd, invoke;
MID obj_class;
MN obj_inst, ref_inst;
int inst_type;
External * access;
int nattrs;
CMISparam * attrs;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct create_arg parm;
register CMISparam * attr = parm.ca_attrs;
PE pe;
if (obj_class)
parm.ca_class = *obj_class; /* struct copy */
else
return argfail(M_CREATE, 0, "Object Class");
if (obj_inst) {
if (inst_type != CA_OBJECT_INST && inst_type != CA_PARENT_INST)
return argfail(M_CREATE, 0, "Instance Type");
parm.ca_instype = inst_type;
parm.ca_inst = *obj_inst; /* struct copy */
}
else {
parm.ca_instype = CA_OBJECT_INST;
parm.ca_inst.mn_type = MN_DN, parm.ca_inst.mn_dn = NULLDN;
}
if (ref_inst)
parm.ca_refinst = *ref_inst; /* struct copy */
else
parm.ca_refinst.mn_type = MN_DN, parm.ca_refinst.mn_dn = NULLDN;
parm.ca_access = access;
parm.ca_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE)
return argfail(M_CREATE, 0, "Attribute Value");
*attr++ = *attrs++;
}
if (build_CMIP_CreateArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Create Argument", mi);
if (RoInvokeRequest(msd, M_CREATE, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_CreateRes (msd, invoke, obj_class, obj_inst, time, nattrs, attrs,
error, err_info, mi)
int msd, invoke;
MID obj_class;
MN obj_inst;
char * time;
int nattrs;
CMISparam * attrs;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct create_res parm;
register CMISparam * attr = parm.cr_attrs;
PE pe;
if (error)
return M_Error(msd, M_CREATE, invoke, NULLMID, NULLMN, NULLCP,
0, NULLMPARM, error, err_info, mi);
if (obj_class)
parm.cr_class = *obj_class; /* struct copy */
else
parm.cr_class.mid_type = MID_GLOBAL, parm.cr_class.mid_global = NULLOID;
if (obj_inst)
parm.cr_inst = *obj_inst; /* struct copy */
else
parm.cr_inst.mn_type = MN_DN, parm.cr_inst.mn_dn = NULLDN;
parm.cr_time = time;
parm.cr_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE)
return argfail(M_CREATE, 1, "Attribute Value");
*attr++ = *attrs++; /* struct copy */
}
if (build_CMIP_CreateResult(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Create Result", mi);
if (RoResultRequest(msd, invoke, M_CREATE, pe, ROS_NOPRIO, &rois)
== NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_Delete (msd, invoke, obj_class, obj_inst, scope, filter,
access, sync, mi)
int msd, invoke;
MID obj_class;
MN obj_inst;
Scope * scope;
CMISfilter * filter;
External * access;
CMISsync sync;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct delete_arg parm;
PE pe;
if (obj_class)
parm.da_class = *obj_class; /* struct copy */
else
return argfail(M_DELETE, 0, "Object Class");
if (obj_inst)
parm.da_inst = *obj_inst; /* struct copy */
else
return argfail(M_DELETE, 0, "Object Instance");
if (scope)
parm.da_scope = *scope; /* struct copy */
else
parm.da_scope.sc_type = Sc_BaseObject;
parm.da_filter = filter;
parm.da_access = access;
parm.da_sync = sync;
if (build_CMIP_DeleteArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Delete Argument", mi);
if (RoInvokeRequest(msd, M_DELETE, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
int M_DeleteRes (msd, invoke, linked, obj_class, obj_inst, time,
error, err_info, mi)
int msd, invoke, linked;
MID obj_class;
MN obj_inst;
char * time;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct delete_res parm;
PE pe;
if (linked) {
if (linked != invoke)
return argfail(M_DELETE, 1, "LinkedId = InvokeId");
return M_LinkedReply(msd, M_DELETE, invoke, obj_class, obj_inst, time,
0, NULLMPARM, NULLMPARM, error, err_info, mi);
}
if (error)
return M_Error(msd, M_DELETE, invoke, NULLMID, NULLMN, NULLCP,
0, NULLMPARM, error, err_info, mi);
if (obj_class)
parm.dr_class = *obj_class; /* struct copy */
else
parm.dr_class.mid_type = MID_GLOBAL, parm.dr_class.mid_global = NULLOID;
if (obj_inst)
parm.dr_inst = *obj_inst; /* struct copy */
else
parm.dr_inst.mn_type = MN_DN, parm.dr_inst.mn_dn = NULLDN;
parm.dr_time = time;
if (build_CMIP_DeleteResult(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Delete Result", mi);
if (RoResultRequest(msd, invoke, M_DELETE, pe, ROS_NOPRIO, &rois)
== NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
static int M_LinkedReply (msd, op, invoke, obj_class, obj_inst, time,
nattrs, attrs, reply, error, err_info, mi)
int msd, op, invoke;
MID obj_class;
MN obj_inst;
char * time;
int nattrs;
CMISparam * attrs, * reply;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
struct linked_reply_arg parm;
PE pe;
if (op == M_GET && (error == m_noError || error == m_getListError)) {
register CMISparam * attr = parm.lr_getr.gr_attrs;
parm.lr_type = error ? LR_GET_LISTERR : LR_GET_RES;
if (obj_class)
parm.lr_getr.gr_class = *obj_class; /* struct copy */
else
parm.lr_getr.gr_class.mid_type = MID_GLOBAL,
parm.lr_getr.gr_class.mid_global = NULLOID;
if (obj_inst)
parm.lr_getr.gr_inst = *obj_inst; /* struct copy */
else
parm.lr_getr.gr_inst.mn_type = MN_DN,
parm.lr_getr.gr_inst.mn_dn = NULLDN;
parm.lr_getr.gr_time = time;
if (error == m_getListError && !nattrs)
return argfail(M_GET, 1, "Get List Error - Attribute List");
parm.lr_getr.gr_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE)
return argfail(M_GET, 1, "Get List Error - Attribute Value");
*attr++ = *attrs++; /* struct copy */
}
}
else
if (op == M_SETC && (error == m_noError || error == m_setListError)) {
register CMISparam * attr = parm.lr_setr.sr_attrs;
parm.lr_type = error ? LR_SET_LISTERR : LR_SET_RES;
if (obj_class)
parm.lr_setr.sr_class = *obj_class; /* struct copy */
else
parm.lr_setr.sr_class.mid_type = MID_GLOBAL,
parm.lr_setr.sr_class.mid_global = NULLOID;
if (obj_inst)
parm.lr_setr.sr_inst = *obj_inst; /* struct copy */
else
parm.lr_setr.sr_inst.mn_type = MN_DN,
parm.lr_setr.sr_inst.mn_dn = NULLDN;
parm.lr_setr.sr_time = time;
if (error == m_setListError && !nattrs)
return argfail(M_SETC, 1, "Set List Error - Attribute List");
parm.lr_setr.sr_nattrs = nattrs;
for (; nattrs--;) {
if (attrs -> mp_val == NULLPE)
return argfail(M_SETC, 1, "Set List Error - Attribute Value");
*attr++ = *attrs++; /* struct copy */
}
}
else
switch (error) {
case m_noError:
switch (op) {
case M_ACTIONC:
parm.lr_type = LR_ACTION_RES;
if (obj_class)
parm.lr_actionr.ar_class = *obj_class; /* struct copy */
else
parm.lr_actionr.ar_class.mid_type = MID_GLOBAL,
parm.lr_actionr.ar_class.mid_global = NULLOID;
if (obj_inst)
parm.lr_actionr.ar_inst = *obj_inst; /* struct copy */
else
parm.lr_actionr.ar_inst.mn_type = MN_DN,
parm.lr_actionr.ar_inst.mn_dn = NULLDN;
if (reply) {
if (reply -> mp_val == NULLPE)
return argfail (M_ACTIONC, 1, "Reply Value");
parm.lr_actionr.ar_reply = *reply; /* struct copy */
}
else
parm.lr_actionr.ar_reply.mp_id.mid_type = MID_GLOBAL,
parm.lr_actionr.ar_reply.mp_id.mid_global = NULLOID,
parm.lr_actionr.ar_reply.mp_val = NULLPE;
parm.lr_actionr.ar_time = time;
break;
case M_DELETE:
parm.lr_type = LR_DELETE_RES;
if (obj_class)
parm.lr_deleter.dr_class = *obj_class; /* struct copy */
else
parm.lr_deleter.dr_class.mid_type = MID_GLOBAL,
parm.lr_deleter.dr_class.mid_global = NULLOID;
if (obj_inst)
parm.lr_deleter.dr_inst = *obj_inst; /* struct copy */
else
parm.lr_deleter.dr_inst.mn_type = MN_DN,
parm.lr_deleter.dr_inst.mn_dn = NULLDN;
parm.lr_deleter.dr_time = time;
break;
default:
(void) fprintf(stderr, "Invalid Linked Operation: %d\n", op);
return NOTOK;
}
break;
case m_processingFailure:
parm.lr_type = LR_PROC_FAIL;
if (err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Processing Failure - Object Class");
parm.lr_error.me_class = err_info -> me_class; /* struct copy */
if ((parm.lr_error.me_val = err_info -> me_val) == NULLPE)
return argfail(op, 1, "Processing Failure - Error Info");
if (err_info -> me_inst.mn_type != MN_DN ||
err_info -> me_inst.mn_dn != NULL)
parm.lr_error.me_inst = err_info -> me_inst; /* struct copy */
else
parm.lr_error.me_inst.mn_type = MN_DN,
parm.lr_error.me_inst.mn_dn = NULLDN;
break;
case m_accessDenied:
switch (op) {
case M_DELETE:
parm.lr_type = LR_DELETE_ERR;
break;
case M_ACTIONC:
parm.lr_type = LR_ACTION_ERR;
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(M_ACTIONC, 1, "Action Error - Action Type Id");
parm.lr_error.me_id = err_info -> me_id; /* struct copy */
break;
default:
(void) fprintf(stderr, "Invalid Linked Operation/Error: %d / %d\n",
op, error);
return NOTOK;
}
parm.lr_error.me_error = error;
if (err_info == NULLMERRPARM) { /* DeleteError: all optional */
parm.lr_error.me_class.mid_type = MID_GLOBAL,
parm.lr_error.me_class.mid_global = NULLOID;
parm.lr_error.me_inst.mn_type = MN_DN,
parm.lr_error.me_inst.mn_dn = NULLDN;
parm.lr_error.me_time = NULLCP;
break;
}
if (err_info -> me_class.mid_type != MID_GLOBAL ||
err_info -> me_class.mid_global != NULLOID)
parm.lr_error.me_class = err_info -> me_class; /* struct copy */
else
parm.lr_error.me_class.mid_type = MID_GLOBAL,
parm.lr_error.me_class.mid_global = NULLOID;
if (err_info -> me_inst.mn_type != MN_DN ||
err_info -> me_inst.mn_dn != NULLDN)
parm.lr_error.me_inst = err_info -> me_inst; /* struct copy */
else
parm.lr_error.me_inst.mn_type = MN_DN,
parm.lr_error.me_inst.mn_dn = NULLDN;
parm.lr_error.me_time = err_info -> me_time;
break;
case m_noSuchAction:
case m_noSuchArgument:
case m_invalidArgumentValue:
if (op != M_ACTIONC) {
(void) fprintf(stderr, "Invalid Linked Operation/Error: %d / %d\n",
op, error);
return NOTOK;
}
parm.lr_type = LR_ACTION_ERR;
if (error == m_noSuchAction &&
err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Action Error (noSuchAction) - Object Class");
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(M_ACTIONC, 1, "Action Error - Action Type Id");
parm.lr_error.me_id = err_info -> me_id; /* struct copy */
if (err_info -> me_class.mid_type != MID_GLOBAL ||
err_info -> me_class.mid_global != NULLOID)
parm.lr_error.me_class = err_info -> me_class; /* struct copy */
else
parm.lr_error.me_class.mid_type = MID_GLOBAL,
parm.lr_error.me_class.mid_global = NULLOID;
if (err_info -> me_inst.mn_type != MN_DN ||
err_info -> me_inst.mn_dn != NULLDN)
parm.lr_error.me_inst = err_info -> me_inst; /* struct copy */
else
parm.lr_error.me_inst.mn_type = MN_DN,
parm.lr_error.me_inst.mn_dn = NULLDN;
parm.lr_error.me_time = err_info -> me_time;
parm.lr_error.me_val = err_info -> me_val;
parm.lr_error.me_error = error;
parm.lr_error.me_operation = op; /* for pepy encoder */
break;
default:
(void) fprintf(stderr, "Invalid Linked Reply Error: %d\n", error);
return NOTOK;
}
if (build_CMIP_LinkedReplyArgument(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("Linked Reply Argument", mi);
if (RoInvokeRequest(msd, M_LINKED_REPLY, ROS_ASYNC, pe, invoke,
NULLIP, ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
pe_free(pe);
return OK;
}
static int M_Error (msd, op, invoke, obj_class, obj_inst, time,
nattrs, attrs, error, err_info, mi)
int msd, op, invoke;
MID obj_class;
MN obj_inst;
char * time;
int nattrs;
CMISparam * attrs;
CMISerrors error;
CMISerrparam * err_info;
struct MSAPindication * mi;
{
struct RoSAPindication rois;
PE pe;
switch (error) {
case m_noSuchObjectClass:
if (err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (noSuchObjectClass) - Object Class");
if (build_CMIP_ObjectClass(&pe, 1, 0, NULLCP, &err_info -> me_class)
== NOTOK)
return buildfail("ObjectClass", mi);
break;
case m_noSuchObjectInstance:
case m_invalidObjectInstance:
case m_duplicateManagedObjectInstance:
case m_noSuchReferenceObject:
if (err_info -> me_inst.mn_dn == NULLDN &&
err_info -> me_inst.mn_type == MN_DN)
return argfail(op, 1, "Error - Object Instance");
if (build_CMIP_ObjectInstance(&pe, 1, 0, NULLCP, &err_info -> me_inst)
== NOTOK)
return buildfail("ObjectInstance", mi);
break;
case m_accessDenied:
case m_invalidOperation:
pe = NULLPE;
break;
case m_syncNotSupported:
if (build_CMIP_CMISSync(&pe, 1, 0, NULLCP, (int *) &err_info -> me_sync)
== NOTOK)
return buildfail("CMISSync", mi);
break;
case m_invalidFilter:
if (err_info -> me_filter == NULLFILTER)
return argfail(op, 1, "Error (invalidFilter) - CMIS Filter");
if (build_CMIP_CMISFilter(&pe, 1, 0, NULLCP, err_info -> me_filter)
== NOTOK)
return buildfail("CMISFilter", mi);
break;
case m_noSuchAttribute:
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error - Attribute Id");
if (build_CMIP_AttributeId(&pe, 1, 0, NULLCP, &err_info -> me_id)
== NOTOK)
return buildfail("AttributeId", mi);
break;
case m_invalidAttributeValue:
{
CMISparam attr;
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (invalidAttributeValue) - \
Attribute Id");
if (err_info -> me_val == NULLPE)
return argfail(op, 1, "Error (invalidAttributeValue) - \
Attribute Value");
attr.mp_id = err_info -> me_id; /* struct copy */
attr.mp_val = err_info -> me_val;
if (build_CMIP_Attribute(&pe, 1, 0, NULLCP, &attr) == NOTOK)
return buildfail("Attribute", mi);
}
break;
case m_getListError:
{
struct get_res parm;
register CMISparam * attr = parm.gr_attrs;
if (obj_class)
parm.gr_class = *obj_class; /* struct copy */
else
parm.gr_class.mid_type = MID_GLOBAL,
parm.gr_class.mid_global = NULLOID;
if (obj_inst)
parm.gr_inst = *obj_inst; /* struct copy */
else
parm.gr_inst.mn_type = MN_DN,
parm.gr_inst.mn_dn = NULLDN;
parm.gr_time = time;
if (!attrs)
return argfail(M_GET, 1, "Get List Error - Attribute List");
parm.gr_nattrs = nattrs;
for (; nattrs--;)
*attr++ = *attrs++; /* struct copy */
if (build_CMIP_GetListError(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("GetListError", mi);
}
break;
case m_setListError:
{
struct set_res parm;
register CMISparam * attr = parm.sr_attrs;
if (obj_class)
parm.sr_class = *obj_class; /* struct copy */
else
parm.sr_class.mid_type = MID_GLOBAL,
parm.sr_class.mid_global = NULLOID;
if (obj_inst)
parm.sr_inst = *obj_inst; /* struct copy */
else
parm.sr_inst.mn_type = MN_DN,
parm.sr_inst.mn_dn = NULLDN;
parm.sr_time = time;
if (!nattrs)
return argfail(M_SETC, 1, "Set List Error - Attribute List");
parm.sr_nattrs = nattrs;
for (; nattrs--;)
*attr++ = *attrs++; /* struct copy */
if (build_CMIP_SetListError(&pe, 1, 0, NULLCP, &parm) == NOTOK)
return buildfail("SetListError", mi);
}
break;
case m_noSuchAction:
if (err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (noSuchAction) - Object Class");
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (noSuchAction) - Action Id");
if (build_CMIP_NoSuchAction(&pe, 1, 0, NULLCP, err_info) == NOTOK)
return buildfail("NoSuchAction", mi);
break;
case m_processingFailure:
if (err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (processingFailure) - Object Class");
if (build_CMIP_ProcessingFailure(&pe, 1, 0, NULLCP, err_info) == NOTOK)
return buildfail("ProcessingFailure", mi);
break;
case m_noSuchEventType:
if (err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (noSuchEventType) - Object Class");
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (noSuchEventType) - Event Type Id");
if (build_CMIP_NoSuchEventType(&pe, 1, 0, NULLCP, err_info) == NOTOK)
return buildfail("NoSuchEventType", mi);
break;
case m_noSuchArgument:
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (noSuchArgument) - \
Action/Event Type Id");
err_info -> me_operation = op; /* for pepy encoder */
if (build_CMIP_NoSuchArgument(&pe, 1, 0, NULLCP, err_info) == NOTOK)
return buildfail("NoSuchArgument", mi);
break;
case m_invalidArgumentValue:
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (invalidArgumentValue) - Action/Event \
Type Id");
err_info -> me_operation = op; /* for pepy encoder */
if (build_CMIP_InvalidArgumentValue(&pe, 1, 0, NULLCP, err_info)
== NOTOK)
return buildfail("InvalidArgumentValue", mi);
break;
case m_invalidScope:
if (build_CMIP_Scope(&pe, 1, 0, NULLCP, &err_info -> me_scope)
== NOTOK)
return buildfail("Scope", mi);
break;
case m_missingAttributeValue:
if (err_info -> me_id.mid_global == NULLOID &&
err_info -> me_id.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (missingAttributeValue) - \
Attribute Id");
if (build_CMIP_AttributeIdList(&pe, 1, 0, NULLCP, &err_info -> me_id)
== NOTOK)
return buildfail("AttributeIdList", mi);
break;
case m_classInstanceConflict:
if (err_info -> me_class.mid_global == NULLOID &&
err_info -> me_class.mid_type == MID_GLOBAL)
return argfail(op, 1, "Error (classInstanceConflict) - \
Object Class");
if (err_info -> me_inst.mn_dn == NULLDN &&
(err_info -> me_inst.mn_type == MN_DN ||
err_info -> me_inst.mn_type == MN_LOCALDN) )
return argfail(op, 1, "Error (classInstanceConflict) - Object \
Instance");
if (build_CMIP_BaseManagedObjectId(&pe, 1, 0, NULLCP, err_info)
== NOTOK)
return buildfail("BaseManagedObjectId", mi);
break;
case m_complexityLimitation:
if (build_CMIP_ComplexityLimitation(&pe, 1, 0, NULLCP, err_info)
== NOTOK)
return buildfail("ComplexityLimitation", mi);
break;
case m_invalidOperator:
if (build_CMIP_ModifyOperator(&pe, 1, 0, NULLCP,
(int *) &err_info -> me_modify) == NOTOK)
return buildfail("ModifyOperator", mi);
break;
default:
(void) fprintf(stderr, "Invalid Error Type: %d\n", error);
return NOTOK;
}
if (RoErrorRequest(msd, invoke, (int) error-1, pe,
ROS_NOPRIO, &rois) == NOTOK)
return rosfail(&rois, mi);
if (pe != NULLPE)
pe_free(pe);
return OK;
}
static int buildfail (s, mi)
char * s;
struct MSAPindication * mi;
{
mi->mi_type = MI_PREJECT;
mi->mi_preject.mr_reason = MA_BADARGS;
(void) sprintf(mi->mi_preject.mr_data, "%.*s: Incorrect Arguments",
MR_SIZE-25, s);
return NOTOK;
}
static int rosfail (roi, mi)
struct RoSAPindication * roi;
struct MSAPindication * mi;
{
mi->mi_type = MI_PREJECT;
mi->mi_preject.mr_reason = roi->roi_preject.rop_reason;
mi->mi_preject.mr_id = roi->roi_preject.rop_id;
(void) strncpy(mi->mi_preject.mr_data, roi->roi_preject.rop_data, MR_SIZE);
ROPFREE(&roi->roi_preject);
return NOTOK;
}
static int argfail (op, res, arg)
int op, res;
char * arg;
{
char * op2str();
if (res)
(void) fprintf(stderr, "%s Result: argument \"%s\" is mandatory\n",
op2str(op), arg);
else
(void) fprintf(stderr, "%s: argument \"%s\" is mandatory\n",
op2str(op), arg);
return NOTOK;
}
static char * op2str (op)
int op;
{
static char buf[16];
switch (op) {
case M_EVENT_REP:
(void) strcpy(buf, "M_EventRep");
break;
case M_EVENT_REPC:
(void) strcpy(buf, "M_EventRepC");
break;
case M_LINKED_REPLY:
(void) strcpy(buf, "M_LinkedReply");
break;
case M_GET:
(void) strcpy(buf, "M_Get");
break;
case M_SET:
(void) strcpy(buf, "M_Set");
break;
case M_SETC:
(void) strcpy(buf, "M_SetC");
break;
case M_ACTION:
(void) strcpy(buf, "M_Action");
break;
case M_ACTIONC:
(void) strcpy(buf, "M_ActionC");
break;
case M_CREATE:
(void) strcpy(buf, "M_Create");
break;
case M_DELETE:
(void) strcpy(buf, "M_Delete");
break;
default:
(void) fprintf(stderr, "op2str: unknown operation code %d\n", op);
buf[0] = '\0';
break;
}
return buf;
}