Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/Vcwindow/vcwmethod.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
/* Return a windowing method by its string name.
23
**
24
** Written by Kiem-Phong Vo ([email protected])
25
*/
26
27
/* List of currently supported windowing methods */
28
_BEGIN_EXTERNS_
29
extern Vcwmethod_t _Vcwprefix;
30
extern Vcwmethod_t _Vcwmirror;
31
extern Vcwmethod_t _Vcwvote;
32
_END_EXTERNS_
33
34
static Vcwmethod_t* _Vcwmethods[] =
35
{
36
&_Vcwprefix,
37
&_Vcwmirror,
38
&_Vcwvote,
39
0
40
};
41
42
#if __STD_C
43
Vcwmethod_t* vcwgetmeth(char* name)
44
#else
45
Vcwmethod_t* vcwgetmeth(name)
46
char* name;
47
#endif
48
{
49
int i, k;
50
51
if(!name)
52
return NIL(Vcwmethod_t*);
53
54
for (i = 0; _Vcwmethods[i]; ++i)
55
{ for(k = 0; name[k] && _Vcwmethods[i]->name[k]; ++k)
56
if(name[k] != _Vcwmethods[i]->name[k])
57
break;
58
if(name[k] == 0) /* match a prefix */
59
return _Vcwmethods[i];
60
}
61
62
return NIL(Vcwmethod_t*);
63
}
64
65
#if __STD_C
66
int vcwwalkmeth(Vcwalk_f walkf, Void_t* disc)
67
#else
68
int vcwwalkmeth(Vcwalk_f walkf, Void_t* disc)
69
Vcwalk_t walkf;
70
Void_t* disc;
71
#endif
72
{
73
int i, rv;
74
75
if(!walkf)
76
return -1;
77
78
for (i = 0; _Vcwmethods[i]; ++i)
79
{ rv = (*walkf)((Void_t*)_Vcwmethods[i],
80
_Vcwmethods[i]->name, _Vcwmethods[i]->desc, disc);
81
if(rv < 0)
82
return rv;
83
}
84
85
return 0;
86
}
87
88