Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
34b365c5
Commit
34b365c5
authored
Jan 31, 2011
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wash and improve the .vcc file parser a little bit
parent
5da592f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
21 deletions
+60
-21
vmod.py
lib/libvmod_std/vmod.py
+60
-21
No files found.
lib/libvmod_std/vmod.py
View file @
34b365c5
...
@@ -40,14 +40,13 @@
...
@@ -40,14 +40,13 @@
# $Id$
# $Id$
import
sys
import
sys
import
re
if
len
(
sys
.
argv
)
==
2
:
if
len
(
sys
.
argv
)
==
2
:
specfile
=
sys
.
argv
[
1
]
specfile
=
sys
.
argv
[
1
]
else
:
else
:
specfile
=
"vmod.vcc"
specfile
=
"vmod.vcc"
type_tab
=
dict
()
ctypes
=
{
ctypes
=
{
'IP'
:
"struct sockaddr_storage *"
,
'IP'
:
"struct sockaddr_storage *"
,
'STRING'
:
"const char *"
,
'STRING'
:
"const char *"
,
...
@@ -114,49 +113,89 @@ def partition(string, separator):
...
@@ -114,49 +113,89 @@ def partition(string, separator):
return
(
string
[:
i
],
separator
,
string
[
i
+
len
(
separator
):])
return
(
string
[:
i
],
separator
,
string
[
i
+
len
(
separator
):])
return
(
string
,
''
,
''
)
return
(
string
,
''
,
''
)
#######################################################################
f
=
open
(
specfile
,
"r"
)
f
=
open
(
specfile
,
"r"
)
for
l0
in
f
:
def
nextline
():
# print("# " + l0)
while
True
:
l0
=
l0
.
strip
()
l0
=
f
.
readline
()
if
l0
==
""
:
return
l0
l0
=
re
.
sub
(
"#.*$"
,
""
,
l0
)
l0
=
re
.
sub
(
"
\
s
\
s*"
,
" "
,
l0
.
strip
())
if
l0
!=
""
:
return
l0
def
is_c_name
(
s
):
return
None
!=
re
.
match
(
"^[a-z][a-z0-9_]*$"
,
s
)
while
True
:
l0
=
nextline
()
if
l0
==
""
:
if
l0
==
""
:
continue
break
;
i
=
l0
.
find
(
"#"
)
l
=
partition
(
l0
,
" "
)
if
i
==
0
:
continue
if
i
>=
0
:
line
=
l0
[:
i
-
1
]
else
:
line
=
l0
line
=
line
.
expandtabs
()
.
strip
()
l
=
partition
(
line
,
" "
)
if
l
[
0
]
==
"Module"
:
if
l
[
0
]
==
"Module"
:
modname
=
l
[
2
]
.
strip
();
modname
=
l
[
2
]
.
strip
();
if
not
is_c_name
(
modname
):
raise
Exception
(
"Module name '
%
s' is illegal"
%
modname
)
continue
continue
if
l
[
0
]
==
"Init"
:
if
l
[
0
]
==
"Init"
:
initname
=
l
[
2
]
.
strip
();
initname
=
l
[
2
]
.
strip
();
if
not
is_c_name
(
initname
):
raise
Exception
(
"Init name '
%
s' is illegal"
%
initname
)
continue
continue
if
l
[
0
]
!=
"Function"
:
if
l
[
0
]
!=
"Function"
:
assert
False
raise
Exception
(
"Expected 'Function' line, got '
%
s'"
%
l
[
0
])
# Find the return type of the function
l
=
partition
(
l
[
2
]
.
strip
(),
" "
)
l
=
partition
(
l
[
2
]
.
strip
(),
" "
)
rt_type
=
l
[
0
]
rt_type
=
l
[
0
]
if
rt_type
not
in
ctypes
:
raise
Exception
(
"Return type '
%
s' not a valid type"
%
rt_type
)
# Find the function name
l
=
partition
(
l
[
2
]
.
strip
(),
"("
)
l
=
partition
(
l
[
2
]
.
strip
(),
"("
)
fname
=
l
[
0
]
.
strip
()
fname
=
l
[
0
]
.
strip
()
if
not
is_c_name
(
fname
):
raise
Exception
(
"Function name '
%
s' is illegal"
%
fname
)
if
l
[
1
]
!=
'('
:
raise
Exception
(
"Missing '('"
)
l
=
l
[
2
]
while
-
1
==
l
.
find
(
")"
):
l1
=
nextline
()
if
l1
==
""
:
raise
Exception
(
"End Of Input looking for ')'"
)
l
=
l
+
l1
if
-
1
!=
l
.
find
(
"("
):
raise
Exception
(
"Nesting trouble with '(...)' "
)
if
l
[
-
1
:]
!=
')'
:
raise
Exception
(
"Junk after ')'"
)
l
=
l
[:
-
1
]
args
=
list
()
args
=
list
()
while
True
:
while
True
:
l
=
partition
(
l
[
2
]
.
strip
(),
","
)
l
=
partition
(
l
,
","
)
if
len
(
l
[
2
])
==
0
:
t
=
l
[
0
]
.
strip
()
if
t
not
in
ctypes
:
raise
Exception
(
"Argument type '
%
s' not a valid type"
%
t
)
args
.
append
(
t
)
l
=
l
[
2
]
if
l
==
""
:
break
break
args
.
append
(
l
[
0
])
l
=
partition
(
l
[
0
]
.
strip
(),
")"
)
args
.
append
(
l
[
0
])
do_func
(
fname
,
rt_type
,
args
)
do_func
(
fname
,
rt_type
,
args
)
#######################################################################
#######################################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment