File: gen-def.py

package info (click to toggle)
libusrsctp 0.9.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 6,604 kB
  • sloc: ansic: 82,365; sh: 176; makefile: 163; python: 48
file content (26 lines) | stat: -rw-r--r-- 602 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
#
# gen-def.py usrsctp.lib
import re
import sys
import subprocess
from shutil import which

try:
    lib_file = sys.argv[1]
except:
    print('Usage: gen-def.py LIB-FILE')
    exit(-1)

print('EXPORTS')

if which('dumpbin'):
    dumpbin_cmd = subprocess.run(['dumpbin', '/linkermember:1', lib_file],
        stdout=subprocess.PIPE)

    pattern = re.compile('\s*[0-9a-fA-F]+ _?(?P<functionname>usrsctp_[^\s]*)')

    for line in dumpbin_cmd.stdout.decode('utf-8').splitlines():
        match = pattern.match(line)
        if match:
            print(match.group('functionname'))