/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 2003-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Phong Vo <[email protected]> *17* *18***********************************************************************/19#include "vchdr.h"2021/* Change the discipline for a Vcodex_t handle.22**23** Written by Kiem-Phong Vo ([email protected])24*/2526#if __STD_C27Vcdisc_t* vcdisc(Vcodex_t* vc, Vcdisc_t* disc)28#else29Vcdisc_t* vcdisc(vc, disc)30Vcodex_t* vc;31Vcdisc_t* disc;32#endif33{34Vcdisc_t *old = vc->disc;35int rv;3637if(!vc)38return NIL(Vcdisc_t*);3940/* check with incumbent to see if it's ok with the change */41if(old && old->eventf &&42(*old->eventf)(vc, VC_DISC, (Void_t*)disc, old) < 0 )43return NIL(Vcdisc_t*);4445/* now announce to method */46if(!vc->meth || !vc->meth->eventf)47rv = 0;48else rv = (*vc->meth->eventf)(vc, VC_DISC, (Void_t*)disc);4950if(rv < 0)51return NIL(Vcdisc_t*);52else if(rv == 0) /* install discipline */53{ vc->disc = disc;54return old ? old : disc;55}56else return disc;57}585960