Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/vcdisc.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "vchdr.h"
21
22
/* Change the discipline for a Vcodex_t handle.
23
**
24
** Written by Kiem-Phong Vo ([email protected])
25
*/
26
27
#if __STD_C
28
Vcdisc_t* vcdisc(Vcodex_t* vc, Vcdisc_t* disc)
29
#else
30
Vcdisc_t* vcdisc(vc, disc)
31
Vcodex_t* vc;
32
Vcdisc_t* disc;
33
#endif
34
{
35
Vcdisc_t *old = vc->disc;
36
int rv;
37
38
if(!vc)
39
return NIL(Vcdisc_t*);
40
41
/* check with incumbent to see if it's ok with the change */
42
if(old && old->eventf &&
43
(*old->eventf)(vc, VC_DISC, (Void_t*)disc, old) < 0 )
44
return NIL(Vcdisc_t*);
45
46
/* now announce to method */
47
if(!vc->meth || !vc->meth->eventf)
48
rv = 0;
49
else rv = (*vc->meth->eventf)(vc, VC_DISC, (Void_t*)disc);
50
51
if(rv < 0)
52
return NIL(Vcdisc_t*);
53
else if(rv == 0) /* install discipline */
54
{ vc->disc = disc;
55
return old ? old : disc;
56
}
57
else return disc;
58
}
59
60