Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/Vcwindow/vcwopen.c
1810 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 "vcwhdr.h"
21
22
/* Open a handle for computing matching windows.
23
**
24
** Written by Kiem-Phong Vo ([email protected])
25
*/
26
27
#if __STD_C
28
Vcwindow_t* vcwopen(Vcwdisc_t* disc, Vcwmethod_t* meth)
29
#else
30
Vcwindow_t* vcwopen(disc, meth)
31
Vcwdisc_t* disc;
32
Vcwmethod_t* meth; /* window matching method */
33
#endif
34
{
35
Vcwindow_t* vcw;
36
37
if(!disc || (!disc->srcf && !disc->tarf) )
38
return NIL(Vcwindow_t*);
39
if(disc->srcf && sfseek(disc->srcf, (Sfoff_t)0, 0) < 0)
40
return NIL(Vcwindow_t*);
41
if(disc->tarf && sfseek(disc->tarf, (Sfoff_t)0, 0) < 0)
42
return NIL(Vcwindow_t*);
43
44
if(!meth)
45
meth = Vcwdecode;
46
47
if(!(vcw = (Vcwindow_t*)calloc(1,sizeof(Vcwindow_t))) )
48
return NIL(Vcwindow_t*);
49
50
vcw->disc = disc;
51
vcw->meth = meth;
52
vcw->mtdata = NIL(Void_t*);
53
54
if(disc->eventf && (*disc->eventf)(vcw, VCW_OPENING, 0, disc) < 0)
55
{ vcwclose(vcw);
56
return NIL(Vcwindow_t*);
57
}
58
59
if(meth->eventf && (*meth->eventf)(vcw, VCW_OPENING) < 0)
60
{ vcwclose(vcw);
61
return NIL(Vcwindow_t*);
62
}
63
64
return vcw;
65
}
66
67